| 1. |
Solve : Moving certain file sizes? |
|
Answer» How would you make a Batch file that moves any file over a certain size to another location?Q: How would you make a Batch file that moves any file over a certain size to another location? I know you can move files but do you want to move files of a specific size like above 2mb?Yes (well, above 200kb, actually). So, you got any ideas?I dunno, hang tight and maybe someone else will have the answer to that. Does it have to be above 200kb, why not the name of the file instead?Quote from: Carbon Dudeoxide on May 01, 2007, 12:47:28 AM I dunno, hang tight and maybe someone else will have the answer to that. I can't use the file name because the point of my program is for the user to just open the batch file and VOILA, instead of having to access to the folder and renaming every file that needs to be renamed (as it is now, I manually changed the name of the ONLY large file, but it won't work on other computers).the below is an example script. change the for loop parameters to suit your needs Code: [Select] for /F "tokens=4* skip=4 delims= " %%A in ('dir /A-D') do ( REM files greater than 40 bytes if %%A GTR 40 ( echo %%B %%A rem your move command here ) ) Thanks. Can you explain what the code means (The command prompt explanation for FOR is a bit too complicated...)?delims mean delimiters so "delims= " mean i am going to use spaces as my delimiter from the dir /A-D output. each "field" separated by the delimiter i call them tokens, so tokens=4* means i am going to get token number 4 onwards, which from the dir /A-D output, is the size in bytes at token 4. Then in the for loop, when i echo %%A , it will the bytes, and if i echo the next token , denoted by %%B, it will be the filename. I hope you understand what i am saying. |
|