View Full Version : Info Simple code to separate archives based on a size-range



jOTTA67h
29th October 2009, 02:55
This is a small module that trawls through a directory containing archives '%STORELOCUP%', separating those that are too small and those too large to a second directory '%STORELOC%'.
The range here is 5MB-40MB (39.999,999MB).
This is useful if you want to upload packed archives to a Premium or a Collector's/Free Account, like RS, FF, etc.


Processing directory showing packed archives
[Only registered and activated users can see links]

Running the module to separate archives 5-40MB
[Only registered and activated users can see links]

Directory 1 showing 5-40MB archive range
[Only registered and activated users can see links]

Directory 2 showing <5 >40MB archive range
[Only registered and activated users can see links]


Obviously you can use something like this from your main pack script and turn it on/off using a switch like 'DOSEP' etc.
I find this quite useful :)



IF /I NOT "%DOSEP%" == "YES" goto :beyond_small_arc
:: ####### Move range arcs outside 5MB-40MB to STORELOC #######
TITLE Move range arcs outside 5MB-40MB to STORELOC
for %%a in (%STORELOCUP%\*.*) do set small_arc="%%~nxa"& call :move_small_arcs
goto :beyond_small_arc

:move_small_arcs
:: Range is 5,000,000 to 39,999,999 bytes
dir %STORELOCUP%\%small_arc% | findstr /i /r /c:"[^0-9][5-9],[0-9][0-9][0-9],[0-9][0-9][0-9] bytes$" > nul || dir %STORELOCUP%\%small_arc% | findstr /i /r /c:"[^0-9][1-3][0-9],[0-9][0-9][0-9],[0-9][0-9][0-9] bytes$" > nul
set errorlev=%errorlevel%

if %errorlev% equ 1 echo. & echo ----- M o v e R a n g e A r c s ----------------------------------- & echo Moving ... %STORELOCUP%\%small_arc% & echo to ... %STORELOC%
if %errorlev% equ 1 move /y %STORELOCUP%\%small_arc% %STORELOC%\ > nul
if %errorlev% equ 1 if %errorlevel% equ 0 echo ... Moved successfully
if %errorlev% equ 1 if %errorlevel% neq 0 echo ... Moved UNsuccessfully
if %errorlev% equ 1 echo --------------------------------------------------------------------- & echo.
goto :eof



:beyond_small_arc


Have fun! :D