Time ago I request some help to develope a short batch file to compress files inside a tree using 7zip, see following link:
Compress separately files within subfolders
Now I want to avoid already zipped files (.7z, .zip files) and jump to the next item.
Also I want to remove previous compressed files (like '.7z.7z' or '.zip.7z') created by using the original batch file several times on a same folder.
This is what I got so far:
@echo off
cd /d %~dp0
rem 7z.exe path
set sevenzip=
if "%sevenzip%"=="" if exist "%ProgramFiles(x86)%\7-zip\7z.exe" set sevenzip=%ProgramFiles(x86)%\7-zip\7z.exe
if "%sevenzip%"=="" if exist "%ProgramFiles%\7-zip\7z.exe" set sevenzip=%ProgramFiles%\7-zip\7z.exe
if "%sevenzip%"=="" echo 7-zip not found&pause&exit
@echo searching...
for /R %%I in (*) do (
if not exist %%I.zip if not exist %%I.7zip "%sevenzip%" a -mx -mmt4 "%%I.7z" -r -x!*.bat "%%I" && "%sevenzip%" t "%%I.7z" * -r
)
del "Compressing_files_7zip.bat.7z"
del *.7z.7z*
del *.zip.7z*
::::::::::::::::::::::::::For setting up shutdown 60' after the end of the process.Remove colons in the line below.
::shutdown.exe /s /t 3600
pause
The main issues I get with this code are:
-I am unable to detect already compressed files and therefore, jump to the next %%I entity.
-Remove non-desirable over-zipped files from sub-folders. Obviously, '*' wildcard does not work inside the loop; on the other hand, if I look for 'del %%I.7z.7z' it does not work either.
I read I cannot use a proper 'OR' fuction for the 'if' loops, that is why I nested them.
Thank you in advance.
Alex.
Aucun commentaire:
Enregistrer un commentaire