yozhic
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Код: @rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @rem :: Script description: :: @rem :: Compress selected dsl files with dictzip.exe :: @rem :: Created on 16.10.2013 :: @rem :: Modified on 01.03.2014 :: @rem :: Version: 0.13 :: @rem :: Copyright: forum.ru-board.com :: @rem :: :: @rem :: TC button 1 parameters: -s "%P" %P%S :: @rem :: compress selected dsl files, keep originals :: @rem :: TC button 2 parameters: -s -r "%P" %P%S :: @rem :: compress selected dsl files, replace originals:: @rem :: TC button 3 parameters: -s -t "%T" %P%S :: @rem :: compress selected dsl files, keep originals :: @rem :: move the files to inactive panel :: @rem :: TC button 4 parameters: -s -r -t "%T" %P%S :: @rem :: compress selected dsl files, replace originals:: @rem :: move the files to inactive panel :: @rem :: TC button 5 parameters: -s -u "%P" %P%S :: @rem :: decompress selected dz files :: @rem :: :: @rem :: TC button 6 parameters: -d "%P" :: @rem :: scan active panel for the dsl files :: @rem :: compress them, keep originals :: @rem :: TC button 7 parameters: -d -r "%P" :: @rem :: scan active panel for the dsl files :: @rem :: compress them, replace originals :: @rem :: TC button 8 parameters: -d -t "%T" "%P" :: @rem :: scan active panel for the dsl files :: @rem :: compress them, keep originals :: @rem :: move the files to inactive panel :: @rem :: TC button 9 parameters: -d -r -t "%T" "%P" :: @rem :: scan active panel for the dsl files :: @rem :: compress them, replace originals :: @rem :: move the files to inactive panel :: @rem :: TC button 10 parameters: -d -u "%P" :: @rem :: scan active panel for the dz files :: @rem :: and decompress them :: @rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @echo off title Batch dictzip setlocal enabledelayedexpansion path %PATH%;%~DP0 set header=%~DP0 set header=%header%header.dat set ext=dsl set keep=1 set param= -k set TitleMode= ( set cmprNumber=0 set ignrNumber=0 if -%1==- goto help if not exist dictzip.exe ( type "%header%" echo The script must be in the same folder as the dictzip.exe call :delay 5 ) if %1==-s ( set prcMode=sel set TitleMode=%TitleMode%selected files if %2==-r ( set TitleMode=%TitleMode%, delete set param= set keep=0 shift ) shift ) if %1==-d ( set prcMode=scan set TitleMode=%TitleMode%active panel if %2==-r ( set TitleMode=%TitleMode%, replace set param= set keep=0 shift ) shift ) if %1==-u ( set TitleMode=%TitleMode%, unzip set param= -d set ext=dz shift ) if %1==-t ( if "%~D2"=="\\" ( echo. type "%header%" echo UNC paths are not supported call :delay 5 ) set TitleMode=%TitleMode%, target set target=yes set outPath=%~2 set logPath=%~DP3 shift & shift ) title Batch dictzip%TitleMode%) if not defined target set logPath=%~1 if %keep%==0 call :alt if %prcMode%==scan ( set dslPath=%~1 goto sPanel ) else if not defined target ( shift ) if -%~X1==- ( type "%header%" echo Can not process selected folders & echo or the files without extension call :delay 8 ) type "%header%" echo Compressing in progress ... :loop if -%1==- goto report if not %~X1==.%ext% ( set /a ignrNumber+=1 goto ignore ) set name=%~DPN1 if "%name:~-5%"=="_abrv" ( set /a ignrNumber+=1 goto ignore ) cd /d %~DP1 dictzip%param%"%~NX1" 2>> "%logPath%errors.log" set err=%errorlevel% set /a cmprNumber+=1 if defined target ( if %err%==0 ( set dic=%name%.dsl.dz set abrv=%name%_abrv.dsl set ann=%name%.ann set bmp=%name%.bmp move /y "!dic!" "%outPath%" > NUL 2>&1 copy /y "!ann!" "%outPath%" > NUL 2>&1 copy /y "!bmp!" "%outPath%" > NUL 2>&1 copy /y "!abrv!" "%outPath%" > NUL 2>&1 ) ) :ignore shift goto loop :report cd /d "%logPath%" if exist errors.log ( dir errors.log | find " 0 bytes" > NUL if !errorlevel!==1 ( goto errors ) else ( del /q errors.log > NUL ) ) if %prcMode%==sel ( set ignr=various ) else ( set ignr=abbrev ) cls & type "%header%" echo Compressing is done & echo. & echo %cmprNumber% %ext% file(s) have been processed if not %ext%==dz echo %ignrNumber% %ignr% file(s) have been ignored call :delay 8 rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :sPanel cd /d "%dslPath%" if not exist *.%ext% ( cls & type "%header%" echo It seems there are no %ext% files in the active directory call :delay 5 ) type "%header%" echo Compressing in progress ... for %%i in ("*.%ext%") do ( set name=%%~Ni if not "!name:~-5!"=="_abrv" ( dictzip%param%"%%i" set err=%errorlevel% set /a cmprNumber+=1 ) else ( set /a ignrNumber+=1 ) if defined target ( if !err!==0 ( set dic=!name!.dsl.dz set ann=!name!.ann set bmp=!name!.bmp set abrv=!name!_abrv.dsl set version=!name!.ver set media=!name!.dsl.files.zip move /y "!dic!" "%outPath%" > NUL 2>&1 copy /y "!ann!" "%outPath%" > NUL 2>&1 copy /y "!bmp!" "%outPath%" > NUL 2>&1 copy /y "!abrv!" "%outPath%" > NUL 2>&1 copy /y "!version!" "%outPath%" > NUL 2>&1 copy /y "!media!" "%outPath%" > NUL 2>&1 ) ) ) 2>>"%logPath%errors.log" goto report :errors if %prcMode%==sel ( set ignr=various ) else ( set ignr=abbrev ) cls & type "%header%" echo %cmprNumber% %ext% file(s) have been processed if not %ext%==dz echo %ignrNumber% %ignr% file(s) have been ignored & echo. & echo. echo Some errors have been detected^^! & echo. & echo Check the errors.log file & echo after you press any key to Exit ... pause > NUL goto :eof rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :help type "%header%" echo The script is designed to be run from the Total Commander echo TC buttons parameters: & echo. echo -s [-r] {[-t "%%T"]/"%%P"} %%P%%S echo -s -u "%%P" %%P%%S echo -d {-u/[-r] [-t "%%T"]} "%%P" & echo. echo -s process selected files "%%T" send target path echo -d scan active panel for files to process "%%P" send source path echo -r remove original files %%P%%S send list of files echo -t define target path -u decompress dz files echo. & echo Press any key to exit ... pause > NUL goto :eof rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: rem :: FUNCTIONS rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :delay rem ping -n 1 -w %1 127.255.255.255 > NUL echo. & timeout /t %1 exit :alt type "%header%" echo Warning! Original dsl's will be deleted & echo Do you want to continue? [Y/N] & echo. set /p Choice=[Y/N] > NUL if /i %Choice%==Y cls & exit /b if /i %Choice%==N ( exit ) else ( cls & goto alt ) | | Всего записей: 2773 | Зарегистр. 20-03-2008 | Отправлено: 21:20 19-07-2015 | Исправлено: yozhic, 21:22 19-07-2015 |
|