Compress several subfolders with batch file (win7)

断了今生、忘了曾经 提交于 2019-12-11 19:52:35

问题


Here's what im trying to achieve using WinRar and Windows batch file:

I have this folder structure

main_folder
- SubDir
- Another_Sub_Dir
- Subdir_2 etc |Note: there are no sub-folders inside sub-folders|

archives_folder
-

On batch run I need all sub-folders inside main_folder to be compressed and then sub-folders deleted. The compressed folders should go inside archives_folder.


回答1:


You can use following command line:

"Path to WinRAR program files directory\Rar.exe" m -agYYYY-MM-DD_N -cfg- -ep1 -inul -m5 -mdg -r -s -tl -y "Complete Path to\archives_folder\Backup_" "Complete Path to\main_folder\"

This command uses console version Rar.exe of WinRAR in program files directory of WinRAR to move all files and subdirectories in main_folder to an archive with name Backup_YYYY-MM-DD_N.rar in directory archives_folder.

YYYY-MM-DD_N is year, month and day on archiving extended by an incremental number starting with 1 in case of running the batch file more than once per day.

The archiving is done recursively using best compression using a solid archive with 4096 KB dictionary size with parent directory path "Complete Path to\main_folder\" not being archived. The archive file gets the time of the newest file inside the archive.

More details about all the switches used can be found in text file Rar.txt in program files directory of WinRAR.



来源:https://stackoverflow.com/questions/22986966/compress-several-subfolders-with-batch-file-win7

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