Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Need batch file help
Name: bryan6565 Date: October 21, 2008 at 15:01:34 Pacific OS: XP CPU/Ram: 2.4Ghz P4/1GB DDR Product: Dell Inspiron 530
Comment:
I have a problem. I am trying to write a batch file which will delete a 0 KB .SPL file and an associated .SHD file, which is not 0 KB. Each .SHD file has the exact filename as the .SPL file, for example: 00001.SPL and 00001.SHD. If 00001.SPL is 0 KB, I want the batch file to delete 00001.SPL and 00001.SHD, regardless of the size of 00001.SHD. What I have so far only deletes the .SPL files. This is what I have to execute the deletion of the .SPL file:
for %%f in ("C:\directorypath\*.spl") do if %%~zf == 0 del %%f
I know I need to assign some variables to pull this off, but I'm not that handy with batch files. Any help will be appreciated.
Name: pball Date: October 21, 2008 at 19:23:14 Pacific
Reply:
for %%f in ("C:\directorypath\*.spl") do ( if %%~zf == 0 ( del %%f del %%~nf.shd ) )
the %%~nf should get you just the file name without the extension and the .shd is the extension.
tested and it works
0
Response Number 2
Name: bryan6565 Date: October 21, 2008 at 19:52:26 Pacific
Reply:
No luck with that. It still left the .SHD file even though it successfully deleted the 0 KB .SPL file. I'm uploading an image of the files in the directory to better describe the issue at hand. I'm wanting the batch file to delete the files with the red boxes around them.
0
Response Number 3
Name: bryan6565 Date: October 21, 2008 at 19:56:29 Pacific
Summary: I need a batch file to copy files from 1 location to another on a network daily. The only problem I have is I dont know the exact folder the files are in as they is generated randomly. The folder cont...
Summary: Hi Could anyone help me figure this out? I’m trying to create a batch file that will go to the C:\ drive and search for the last folder created (e.g SU550) then create a new folder called SU5...
Summary: Wow! Thatnks for all the info guys!!! I'm learning a great deal here :) The onlt reason I wanted this batch file to clean up the folders was because of the 30 PC Machines I have to do this to every so...