I like to back up my old data, and I have a ton of directories with hundreds of thousands of files in them. Compressing them would make them 1. much smaller, and 2. easier to store. But compressing everything into one file would be dangerous and very difficult to manage, and compressing every folder individually would take forever.
Fortunately, 7-zip has some nice command line tools. Using these, I wrote a small script that I can put anywhere, and double-clicking on it will compress every folder next to the script into a separate .zip file, AND test them for errors. Here's how:
Compressing
Step 1: Get 7-zip (Google it).
Step 2: Make a new text file, and paste in the following code (in blue):
@echo off
for /d %%G in (*) do "C:\Program Files (x86)\7-Zip\7z.exe" a "%%G.zip" "%%G\" -mmt
for %%G in (*.zip) do "C:\Program Files (x86)\7-Zip\7z.exe" t "%%G" * -r | FIND /v "Testing " | FIND /v "Copyright "
pause
NOTE: You may need to change the "C:\Program Files (x86)\7-Zip\7z.exe" sections to point to where you installed 7-zip, if it's different from me.
Step 3: Save this file with any name, with the .bat extension (for example, batch-compressor.bat).
Step 4: Put this file somewhere that has a bunch of directories in it.
Step 5: Double-click the file (do NOT run as administrator). A command prompt will pop up and show you the progress. When it is done, look through and make sure there were no errors and all the sections say "Everything is OK".
You should notice a bunch of .zip files next to your folders now! Just delete the folders if you don't want them anymore, and keep the .zip files.
Notes:
- This only compresses folders and the files in those folders, not files in the same directory. You'll need to do that yourself if you want.
- This does not delete the original folders; if you want to do that, just delete them when it's done. Make sure your drive has enough room for all the new .zip files, especially if you're compressing a lot of data.
- Personally, I would recommend not making each zip file larger then a few GB each, preferably much smaller. Too big archives are at higher risk of corruption or some issue happening, which would affect a larger amount of data, and it's also a pain if you want to move specific files around later.
Now how do you decompress (extract) these archives you just made? Again, decompressing them manually would take forever. Well, there's a script for that too.
Step 1: Make a new batch file, the same way as above. Paste in the following code (in blue):
@echo off
for %%G in (*.zip) do "C:\Program Files (x86)\7-Zip\7z.exe" x "%%G" -mmt
pause
NOTE: Again, you may need to change the "C:\Program Files (x86)\7-Zip\7z.exe" section to point to where you installed 7-zip, if it's different from me.
Step 2: Save the file with a new name, and as a .bat (for example, batch-decompressor.bat)
Step 3: Put the file next to all the archives you want to extract.
Step 4: Double-click the file (do NOT run as administrator). A command prompt will pop up and show you the progress.
And you're done! Now you have a way to compress lots of folders into individual archives, and a way to extract all of them again in one fell swoop.
Happy archiving!
Step 1: Make a new batch file, the same way as above. Paste in the following code (in blue):
@echo off
for %%G in (*.zip) do "C:\Program Files (x86)\7-Zip\7z.exe" x "%%G" -mmt
pause
NOTE: Again, you may need to change the "C:\Program Files (x86)\7-Zip\7z.exe" section to point to where you installed 7-zip, if it's different from me.
Step 2: Save the file with a new name, and as a .bat (for example, batch-decompressor.bat)
Step 3: Put the file next to all the archives you want to extract.
Step 4: Double-click the file (do NOT run as administrator). A command prompt will pop up and show you the progress.
And you're done! Now you have a way to compress lots of folders into individual archives, and a way to extract all of them again in one fell swoop.
Happy archiving!