Ruddzy Posted March 15, 2012 Posted March 15, 2012 (edited) gday folks, trying to delete all avi's under 20mb if ive got a .exe with this code in the same folder as the avi's it works fine for /f "usebackq delims=;" %%A in (`dir /b *sample*.avi`) do If %%~zA LSS 20971520 del "%%A"however when i try and get a bit more inventive, and try the code below, all i get is windows cannot find the pathfor %%A in ('dir "%directory%\*.avi"') do If %%~zA LSS 20971520 del "%%A"any help would be more than appreciatedcheers Edited March 15, 2012 by Ruddzy
jaclaz Posted March 15, 2012 Posted March 15, 2012 (edited) however when i try and get a bit more inventive ....It's not about being inventive, it's about not knowing some command syntax/not experimenting on command line. Try executing in a command prompt:dir "yourpath\*.avi"then try again with:dir /b "yourpath\*.avi"DIr (without /b ) will have a "type" of output (NOT compatible with using the %%A variable), Dir /b will have another "type" of output.And, in any case, you cannot remove the /F in the FOR command!Read:http://www.robvanderwoude.com/ntfor.phpAnd, additionally the ~z won't work with "different from current" path. In your posted example, what you want is most probably a .cmd (AND NOT a .exe) like:@ECHO OFFSETLOCAL ENABLEEXTENSIONS.........PUSHD %directory%FOR /F %%A in ('DIR /B "*.avi"') DO IF %%~zA LSS 20971520 ECHO DEL "%%A"POPDthe ECHO is there just to "protect the innocents" .jaclaz Edited March 15, 2012 by jaclaz
CoffeeFiend Posted March 15, 2012 Posted March 15, 2012 A quick powershell one-liner, for anyone who might be interested:ls C:\somepath\ | ? { $_.Length -lt 20MB } | rm
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now