Retro-Starr Posted January 23, 2010 Share Posted January 23, 2010 I have a script were I need to make it recursively search for 100kB and delete them. The problem is that once files are in a folder, the script doesn't care for the size and deletes everything in the folders. :: @echo off :: schtasks /create /sc hourly /tn "Search and Destroy" /tr "goto :task" :task for /r %%g in (*.wav) do [ goto :check ] :check :: 102400 is in bytes and equates to 100kB if %~z1 leq 102400 ( :: del /q /f %1 del /q /f %%g goto :next_arguement ) else ( goto :end ) :next_arguement shift goto :check :end pause > nul exit /b This code should be structurally correct, but the "del /q /f %%g" doesn't delete anything unless it's "del /q /f %1" which is the command that loves to delete everything! The search for the wav files doesn't work either. I've been working on this for the past couple of days and am lucky I got this far! I would really appreciate any help on this. Quote Link to comment Share on other sites More sharing options...
Sparda Posted January 23, 2010 Share Posted January 23, 2010 Is it because %%G is set on line for /r %%g in (*.wav) do [ and contains the path/name of every file that goes to :check? Quote Link to comment Share on other sites More sharing options...
Retro-Starr Posted January 23, 2010 Author Share Posted January 23, 2010 I want it to read, for every wav file in directory check the size then act accordingly and move onto the next folders. I don't know if that's what the computer is reading it as, but to mean it seems fine *shrugs*. Quote Link to comment Share on other sites More sharing options...
Retro-Starr Posted January 23, 2010 Author Share Posted January 23, 2010 I got it! It required a "%%~zg", notice the double %% instead of the %~zg (or a numeric value). Credit goes to farhankazi for providing the working script. I just modded it and compared to my script to find out the %%~zg and that the shift was redundant! http://www.experts-exchange.com/Programmin...Q_22944345.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.