View previous topic :: View next topic |
Author |
Message |
aLexx
Joined: 14 Mar 2005 Posts: 442 Location: Новокузнецк
|
(Separately) Posted: Tue Dec 16, 2008 19:38 Post subject: |
|
|
К сожалению, в консольной версии RAR упаковки в ZIP нету... |
|
Back to top |
|
|
_Johm
Joined: 14 May 2006 Posts: 119
|
(Separately) Posted: Wed Dec 17, 2008 10:30 Post subject: |
|
|
Недавно снова понадобилась эта функция. Обнаружил что бат файл не работает когда папка-источник не совпадает с папкой-целью.
Не стал больше делать это в бат-файле. Написал vbscript
VBS файл и кнопка для Total Commander.
пакетная упаковка папок в zip без сжатия и
без основной папки в создаваемом архиве
с помощью winrar.exe (ключи можно настроить
на свой вкус)
Выделяем файлы/папки в одной панели,
архивация происходит в другую.
Code: |
'параметры
rem %L
rem "%T"
rem (zip|rar) тип архива
rem (0|1|2|3|4|5) степень сжатия (0 - без сжатия)
rem пропускать файлы? (0-no|1-yes) пропускать файлы из выделения,т.е. сжимать только выделенные папки.
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim WshShell : Set WshShell = CreateObject("WScript.Shell")
Dim Resp : Resp = ""
Dim Args : Set Args = WScript.Arguments
Dim TCL : TCL = Split(fso.OpenTextFile(Args(0)).ReadAll, vbNewLine)
Dim Target : Target = Args(1)
Target = Replace(Target, """", "")
Dim TARG : Dim SOURCE
Dim ArcType : ArcType = Args(2)
Dim Compression : Compression = Args(3)
Dim SkipFiles : SkipFiles = Args(4)
Dim CurArc
Dim t
Dim skip
For Each CurArc in TCL
If CurArc = "" Then WScript.Quit
skip = ""
If Right(CurArc,1) = "\" Then
t = CurArc & "=end="
TARG = Replace(t, "\=end=", "." & ArcType)
TARG = Target & fso.GetFileName(TARG)
SOURCE = Replace(t, "\=end=", "\*")
ElseIf SkipFiles = 0 Then
t = fso.GetBaseName(CurArc) & "." & ArcType
TARG = Target & t
SOURCE = CurArc
Else skip = "=skip="
End If
If Not skip = "=skip=" Then
TARG = """" & TARG & """"
SOURCE = """" & SOURCE & """"
Resp = "%COMMANDER_PATH%\PLUGINS\arc\winrar.exe a -r -ep1 -af" & ArcType & " -m" & Compression & " -ibck " &TARG & " " & SOURCE
'winrar.exe a -r -ep1 -af%3 -m%4 -ibck !target_path! !source_path
WshShell.Run Resp, 10, True
End If
Next
|
старый bat-файл
Code: |
@echo off
rem Batch packing of albums into ZIP
rem parameters for Total Commander
rem %1 - %F
rem %2 - "%T"
rem %3 - (zip|rar) тип архива
rem %4 - compression (0|1|2|3|4|5) степень сжатия (0 - без сжатия)
rem %5 - miss files? (0-no|1-yes) пропускать файлы из выделения, rem т.е. сжимать только выделенные папки.
set miss_files=%5
chcp 1251 >nul
setlocal enabledelayedexpansion
for /f "delims=" %%a in (%1) do (
set target_path=%~2
set temp_a=%%a
set whatis_a=!temp_a:~-1!
if !whatis_a!==\ (
set temp_a=!temp_a:~0,-1!
echo packing:: !temp_a!.%3
set source_path="%%~fa*"
set target_path="!target_path!!temp_a!.%3"
%COMMANDER_PATH%\PLUGINS\arc\winrar.exe a -af%3 -r -ep1 -m%4 -ibck !target_path! !source_path!
)
if !whatis_a! NEQ \ (
if !miss_files!==0 (
set temp_a=%%~na
echo file packing:: !temp_a!.%3
set source_path="%%~fa"
set target_path="!target_path!!temp_a!.%3"
%COMMANDER_PATH%\PLUGINS\arc\winrar.exe a -af%3 -m%4 -ibck !target_path! !source_path!
)
)
)
endlocal
pause
|
Кнопка
TOTALCMD#BAR#DATA
%COMMANDER_PATH%\PROGS\bat\winrar_music_library.bat
%L "%T" zip 0 1
%COMMANDER_PATH%\PROGS\bat\winrar_music_library.bmp
Batch Packing of Albums into ZIP
%COMMANDER_PATH%\PROGS\bat\
-1
поправил бат и кнопку, благодаря Tol!k
Last edited by _Johm on Sun Apr 12, 2009 20:19; edited 3 times in total |
|
Back to top |
|
|
Tol!k
Joined: 01 Apr 2008 Posts: 1727 Location: Арзамас
|
(Separately) Posted: Wed Dec 17, 2008 20:24 Post subject: |
|
|
_Johm wrote: | ;не смог убрать расширение из переменной temp_a. |
А если расширение не передавать?
Code: | set temp_a="%%~dpna" |
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|