batch file - Using a loop to rar multiple subfolders in a main folder -


i have main folder 3 subfolders ...

  • c:\users\admin\folder
    • folder1
    • folder2
    • folder3

i want batch script grabs first subdirectory folder1, copy location, example c:\temp\folder , winrar starts archive folder1. after copying folder1 location can deleted in main folder.

after winrar finished archiving folder1 can deleted in c:\temp\folder. .rar files remain.

then script starts new folder2 , same folder1.

so far have , not know how implement above.

"c:\program files\winrar\rar.exe" -ep1 -mt5 -v50m -r -df "name-of-the-rar-file" "c:\users\admin\folder\*.*" 

open command prompt window, type , execute for /? , read output command. option /d explained on first page executing commands on each subdirectory of directory.

the batch file below archives each subfolder in c:\users\admin\folder using console version of winrar command m (move = archive , delete on success) instead of command a switch -df.

@echo off /d %%f in ("c:\users\admin\folder\*") (     "%programfiles%\winrar\rar.exe" m -cfg- -ep1 -inul -m5 -mt5 -r -tl -v50m -y "%%~f.rar" "%%~f\"     rd "%%~f" ) 

so result is

  • c:\users\admin\folder
    folder1.rar
    folder2.rar
    folder3.rar

the folder can contain more files after archiving , deletion of folders depending on size of files of folders , how 50 mb volumes necessary archive each folder.

the folder name folder1 not included in file folder1.rar because of backslash in last parameter "%%~f\" @ end of third line.

the batch file can easier if folder name folder1 should included in archive file folder1.rar

@echo off /d %%f in ("c:\users\admin\folder\*") (     "%programfiles%\winrar\rar.exe" m -cfg- -ep1 -inul -m5 -mt5 -r -tl -v50m -y "%%~f.rar" "%%~f" ) 

i don't think copying each folder temporary folder archiving necessary here.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -