I have a bunch of files in a directory and want to 7zip each one into its own 7zip archive
So, for example, 1.csv, 2.csv, 3.csv will end up as 1.7z, 2.7z, 3.7z
Is this possible with a .bat file in Windows 7? I'm using 7zip 9.29 alpha
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityI have a bunch of files in a directory and want to 7zip each one into its own 7zip archive
So, for example, 1.csv, 2.csv, 3.csv will end up as 1.7z, 2.7z, 3.7z
Is this possible with a .bat file in Windows 7? I'm using 7zip 9.29 alpha
This should do what you want (well, almost, 1.csv will be 1.csv.7z):
for %f in (*.csv) do "c:\program files\7-zip\7z.exe" a -t7z %f.7z %f
If you run this in a batch file you need to change %f to %%f.
Also, if the files 1.csv.7z
already exist in the directory, you need to delete them first. The following command line should do that:
for %f in (*.csv) do del %f.csv
for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.7z" "%%X\" -mx=9 -ms=on -md=26 -mfb=256