html_menu

Friday, May 29, 2015

How to make rar archive from files inside many folders and then delete original folders.

How to make rar archive from files inside many folders and then delete original folders (but be sure that you have enough free space on disk):
@echo off
set path="C:\Program Files\WinRAR\";%path%

for /D %%f in ("*") do (
         rar  m -m5 -ep1 -r -v4000M "%%~nxf.rar" "%%f/*"
         rem rd /q /s "%%f"
         rem echo "delete %%f"
) 

And improved version, offer choice at beginning to not run file by mistake and mess up your data:
@echo off

set path="C:\Program Files\WinRAR\";%path%

set /P c=Are you sure you want to continue[Y/N]?
if /I "%c%" EQU "Y" goto :action
if /I "%c%" EQU "N" goto :exit
goto :choice

:action
for /D %%f in ("*") do (
   rar  m -m5 -ep1 -r -v4000M "%%~nxf.rar" "%%f/*"
   rd /q /s "%%f"
   echo "delete %%f"
)
exit 

:exit
exit

No comments:

Post a Comment