How to create sequential 7-Zip from files then delete the original once done using batch file.
My 7zip batch compresses all files and then deletes the original files after compression is completed. (If you don't want to delete them, then just remove or rem out the deletion statement)
Note:
Don't forget to set .bat file properties to [READ ONLY] else It'll be a one-way trip ;)
7z.exe must be installed in its default dir (C:\Program Files\)
Study the script and choose your own source and destination path if you don't like how I've set it up. However, it worked just fine as it is, which is the reason and purpose behind this video.
**Why did I make this How-To video when there are already allot out there?**
Honestly, I can't find a tutorial that really tells me exactly how on this great age internet. Seriously. I really hate going through those how-to's written by others. It's like I can never quite get it right when following their scripts. What I really want is a video that shows me how it's done, in a way that even a layperson can understand. But I've had no luck finding one like that. So, I ended up going through a lot of trial and error to create a script that suits my specific needs for the 7-zip conversion. I am pleased with this batch file that I've created. This customized script is straight to the point for performing the 7-zip conversion according to my desired specifications.
**Copy the below script to make it into a bat file using notepad. **
========================================
set "sevenzip=C:\Program Files\7-Zip\7z.exe"
set "source=C:\Temp\[-7z Compression]"
set "destination=C:\Temp\[-7z Compression]\(USA)"
for %%F in ("%source%\*.*") do (
"%sevenzip%" a -mx9 -mmt "%destination%\%%~nF.7z" "%%F"
del "%%F"
)
pause
==============================================================================
*This modification excludes the '7z compress now.bat' file from compression, which I find annoying. It accomplishes this without the need for looping, which can consume processing time.*
(You can also substitute the name "'7z compress now.bat" with whatever you want to name your bat file.)
==============================================================================
set "sevenzip=C:\Program Files\7-Zip\7z.exe"
set "source=C:\Temp\[-7z Compression]"
set "destination=C:\Temp\[-7z Compression]\(USA)"
if exist "%source%\7z compress now.bat" (
set "excludeFile=%source%\7z compress now.bat"
) else (
set "excludeFile="
)
for %%F in ("%source%\*.*") do (
if not "%%~dpnxF"=="%excludeFile%" (
"%sevenzip%" a -mx9 -mmt "%destination%\%%~nF.7z" "%%F"
del "%%F"
)
)
pause
/- Have fun/