Sunday, April 27, 2014

Useful script(let) #1

A lot of times I want to compress files, like backups, but not glob it all into a single archive.  Rather than do it by hand, a command-line like the following:
@for %f in (*.*) do 7za a "Compressed\%f.7z" "%f" & move /Y "%f" "Delete\%f"
is useful.  Of course, rather than spend the twenty minutes every blue moon re-inventing this, and looking up the command separator symbol for DOS ("&"), etc., I will just post it here, in all it's simplistic glory, and perhaps one day in the future, remember to look it up here again.

This command will go through all files in a directory and create corresponding compressed version in the "compressed" folder and move the uncompressed file to the "delete" folder.  The folders need to exist first, of course.