I found a batch file at SourceForge (original version quoted at the bottom) that does it exactly as I need, but for a little difference: it leaves the compressed files and directories mixed on the original directory to where I copy the batch file and launch it. Not quite a problem if compressing only a handful of files, but when there are thousands of directories and files it requires a very long time to separate them, and as some are not compressed it can become a real headache, waste of time and patience.
I placed a redirection after the operation (added in green), but is doesn't work. The result at the end of the command is Access is denied. It is a trial directory and also a trial path. I tried the path for the new existing directory both with and without quotes with the same result.
Obviously, my problem is ignorance and that is what makes me ask for help. I searched the internet and found many tutorials, searched them, but not what I am looking for.
How can I redirect the output of the 7zip compressed files and directories to another directory, or maybe better, make the batch file make a new one and redirect the output of 7zip into it?
Any suggestions will be most welcome. Thank you.
Best wishes for Christmas and New Year.
Quote
:begin
for /f "delims=" %%i in ('dir /b /ad') do (call :zipdir "%%i")
goto end
:zipdir
"C:\Program Files\7-Zip\7z.exe" a -t7z %1.7z %1\
if errorlevel 1 goto error
"C:\Program Files\7-Zip\7z.exe" t %1.7z >> "C:\Users\Administrator\Desktop\Compressed"
if errorlevel 1 goto error
echo rmdir /S /Q %1\
goto :eof
:error
goto :eof
:end



Help
Back to top









