| 1. |
Solve : Run 2 Commands, Keep Smallest File? |
|
Answer» Hi again everyone, The q and x files could be the same size. What should happen if that occurs? Well, the two different commands use two completely different compression algorithms. It is very unlikely that they would be exactly the same filesize. But, in that event, I would say it's BETTER to keep the .q file and delete the .x file. Thanks.Test this on some sample files. Code: [Select]echo off for /r DIR_1 %%a in (*) do ( dime -D CO=Q -L %%~dpa "%%a" "%%a.q" make -D CO=X -L %%~dpa "%%a" "%%a.x" for %%b in ("%%a.q") do for %%c in ("%%a.x") do if %%~zc LEQ %%~zb (del "%%a.x") else (del "%%a.q") ) pause Quote from: foxidrive on December 09, 2014, 03:59:57 AM Test this on some sample files. Thanks! Always appreciate the help. Quote from: foxidrive on December 09, 2014, 03:59:57 AM Test this on some sample files. Quick follow-up question: If I wanted to add a third command that would produce a ".z" file, how would I go about adding it in the comparison portion of the script? In other words, what would I need to add to compare 3 files and keep the smallest and delete the 2 larger files? The extra command would be identical to the other two except the file extension would be .z, like so: Code: [Select] make -D CO=X -L %%~dpa "%%a" "%%a.z" I'm hoping it's easy so I can, if need be, add more commands and not need to BOTHER you guys with this one again. Any help would be great.It's not totally straight forward to add one, two, or more commands, with tests. Batch files are frequently written for a SINGLE task and when the task changes, then the batch file can be very different. If you have a task to solve and want a script (rather than just a tip on how to use a technique) then always describe the full task - never ask for a simplified version and add things later. The reason is that the volunteers find little enjoyment in writing a script, and then having to change it because the task wasn't described accurately. http://stackoverflow.com/questions/27422598/this-batch-script-wont-work-why |
|