Batch file to compress subdirectories

前端 未结 5 1030
广开言路
广开言路 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:40

    Here's how to do it in 7-zip.

    Let's assume your files are in folder C:\Pictures\. Then you can use the following batch command to create multiple archives with the same name as your directories.

    FOR /D %%i IN (c:\Pictures\*.*) DO "c:\Program Files\7-Zip\7z.exe" a "%%i.zip" "%%i\"

    This will compress each folder in the directory Pictures. Change c:\Pictures to the directory containing your folders. If 7-zip is installed to a different directory, change the "c:\Program Files\7-Zip\7z.exe" to a directory where 7-zip is installed.

提交回复
热议问题