Zipping all files and subdirectories inside a folder using batch file

 ̄綄美尐妖づ 提交于 2020-01-02 20:18:08

问题


I wrote the below script to zip all the files and sub directories inside a folder. But I am only getting the sub directories zipped. What am I doing wrong here? Please advice.

FOR /D %%i IN ("*") DO "C:\Program Files (x86)\WinRAR\WinRAR.exe" a ../../../apps-1.0.2.zip "%%~fi\"

回答1:


Give a try for this example and tell me the results :

-R Switch : for recurring subfolders

-AF<Type> Switch : specify the archive format

-EP1 Switch : to exclude the names of the basic folder

-DH Switch: open shared files : Can process files opened by other applications. This switch is useful if an application allows access the file read, but if all access is prohibited, the file open always fail.

@echo off
Set Winrar=%ProgramFiles%\WinRAR\WinRAR.exe
Set MyFolder=%USERPROFILE%\Favorites
Set ArchiveName=apps-1.0.2.zip
"%Winrar%" a -r -afzip -ep1 -dh "%ArchiveName%" "%MyFolder%"
pause

Edit on 29/06/2016 @13:30

For others switchs and commands you can execute this batch to open the help file of Winrar :

@echo off
Set WinrarHelp=%ProgramFiles%\WinRAR\WinRAR.chm
Start "" "%WinrarHelp%"


来源:https://stackoverflow.com/questions/38088275/zipping-all-files-and-subdirectories-inside-a-folder-using-batch-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!