Batch file to compress subdirectories

前端 未结 5 1031
广开言路
广开言路 2021-02-10 09:56

I am trying to write a batch script that will run automatically compressing subdirectories using winrar or 7-zip:

Example:

 My Pictures
    Pics1 (Pics1.         


        
5条回答
  •  我在风中等你
    2021-02-10 10:54

    Thank you for the great script, I just had 3 issues/changes - directory names with space in name were not working, I just wanted to backup level 1 subdirectories and I wanted to pack all the subdirectories in the current directory (it's great for quick backup of all subdirectories separately). Here is the modification if you need something similar:

    set zip="C:\Program Files\WinRAR\rar.exe" a -r -u -df
    dir /b /o:n /ad > .\folders.txt
    for /F "tokens=*" %%A in (.\folders.txt) do if not exist ".\%%~nA.rar" %zip% ".\%%~nA.rar" "%%A"
    

提交回复
热议问题