Can somebody help me write a WINRAR command line batch file to archive file/folder in RAR format (using WINRAR)
1. The script will find any type of files or folders in current directory (or better yet, I can specify where it should look).
2. If a file was found, it will archive that file (in RAR format) with the same name as the source (eg: pictures.jpg -> pictures.rar).
3. If a folder was found, it will archive all files inside that folder (in RAR format) with the same name as the folder (eg: folder "driver" -> driver.rar).
4. Compression method of that RAR file must be "Store" and it is password-protected.
Somebody wrote this batch file for me few years ago (great thanks!) but it only archive files & doesn't work for folders. I hope somebody can modify it.
@REM ------- BEGIN rar_files.cmd ----------------
@setlocal
@echo off
set path="C:\Program Files\WinRAR\";%path%
rem loop through all of the files
FOR /F "delims==" %%i IN ('dir /s /b *.*') DO call :do_rar "%%i"
pause
goto :eof
:do_rar
rem @echo off
echo %1
rar a -ep -hpPASSWORDGOESHERE -m0 %1.rar %1
popd
REM ------- END BEGIN rar_files.cmd ------------------
Question
reeson
Can somebody help me write a WINRAR command line batch file to archive file/folder in RAR format (using WINRAR)
1. The script will find any type of files or folders in current directory (or better yet, I can specify where it should look).
2. If a file was found, it will archive that file (in RAR format) with the same name as the source (eg: pictures.jpg -> pictures.rar).
3. If a folder was found, it will archive all files inside that folder (in RAR format) with the same name as the folder (eg: folder "driver" -> driver.rar).
4. Compression method of that RAR file must be "Store" and it is password-protected.
Somebody wrote this batch file for me few years ago (great thanks!) but it only archive files & doesn't work for folders. I hope somebody can modify it.
@REM ------- BEGIN rar_files.cmd ---------------- @setlocal @echo off set path="C:\Program Files\WinRAR\";%path% rem loop through all of the files FOR /F "delims==" %%i IN ('dir /s /b *.*') DO call :do_rar "%%i" pause goto :eof :do_rar rem @echo off echo %1 rar a -ep -hpPASSWORDGOESHERE -m0 %1.rar %1 popd REM ------- END BEGIN rar_files.cmd ------------------Link to comment
Share on other sites
1 answer to this question
Recommended Posts