hackoofr

7z_Compress_Multi-subfolders.bat

Dec 25th, 2022
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.83 KB | Source Code | 0 0
  1. @echo off
  2. Title 7z Compressing multi-subfolders
  3. :: set the current directory to the batch file location
  4. cd /d %~dp0
  5. Call :Check_7Zip
  6. @for /d /r %%D in (*) do (
  7.     PUSHD %%D
  8.     @for %%A in (*.*) do (
  9.         echo "%Zip%" a "%%D.7z" "%%A"
  10.         "%Zip%" a "%%D.7z" "%%A"
  11.         If Exist "%%A" Del "%%A"
  12.     )  
  13.     POPD
  14. )
  15. pause
  16. Exit
  17. ::-----------------------------------------------------------------------------------------------------------------------------
  18. :Check_7Zip
  19. Reg Query "HKEY_CURRENT_USER\SOFTWARE\7-Zip" /v "Path">nul 2>&1
  20. If [%errorlevel%] EQU [1] ( echo 7-Zip Not found !
  21.     ) else (
  22.     @FOR /f "tokens=2*" %%i in ('Reg Query "HKEY_CURRENT_USER\SOFTWARE\7-Zip" /v "Path" 2^>nul') do (Set "Zip=%%j7z.exe")
  23. )
  24. Exit /B
  25. ::-----------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment