0

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.

Mofi
  • 46,139
  • 17
  • 80
  • 143
mr.d
  • 386
  • 4
  • 18

1 Answers1

0

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.

Mofi
  • 46,139
  • 17
  • 80
  • 143