Using the WinRAR command line (
C:\Program Files\WinRAR\Rar.exe), what I'm trying to do is compress a single folder in a main folder (
C:\Users\%username%\desktop\mainFolder) to a new folder (
C:\Users\%username%\desktop\newFolder) and delete the single folder after compression in the main folder.
So that ONLY the first subfolder is compressed every time I start the .bat
So far that does only work for all folders which are in the main folder
"C:\Program Files\WinRAR\Rar.exe" a -ep1 -mt5 -m1 -v50M -r "!_RndAlphaNum!" C:\Users\%username%\Desktop\mainFolder\
!_RndAlphaNum! is because I use a code at batch start that generates random names for the .rar archives.
That is similar to Using a loop to rar multiple subfolders in a main folder and can be therefore easily achieved with
@echo off for /D %%F in ("%USERPROFILE%\mainFolder\*") do ( "%ProgramFiles%\WinRAR\Rar.exe" m -ep1 -mt5 -m1 -v50M -r "%USERPROFILE%\desktop\newFolder\%_RndAlphaNum%" "%%~F" goto Done ) :Done
goto Done results in breaking FOR loop after processing first directory and continue the batch job below label
Again command m is used instead of a to archive and then delete all files and folders packed into the archive file created directly in the destination folder.