Can I create a button/hotkey for immediate packing?
Moderators: white, Hacker, petermad, Stefan2
Can I create a button/hotkey for immediate packing?
Hi!
How could I do something like this:
Create a button and/or a hotkey, which when pressed/clicked would compress the selected files in the same folder (or an arbitrary one, or the folder in the other panel ) in a specific archive format.
It would be even better if I could use different compression settings as in the packer window, but for the button/hotkey specifically.
(A long time ago somone told me how to define a hotkey to compress in the same folder but, I've forgotten how.)
How could I do something like this:
Create a button and/or a hotkey, which when pressed/clicked would compress the selected files in the same folder (or an arbitrary one, or the folder in the other panel ) in a specific archive format.
It would be even better if I could use different compression settings as in the packer window, but for the button/hotkey specifically.
(A long time ago somone told me how to define a hotkey to compress in the same folder but, I've forgotten how.)
I tried a achieving it by using an external exe. This is as far as I got so far:
I used 7zg.exe because it seems to do the same thing only it doesn't show the command line window.
It's mostly what I want. It'll always have the name of the first file though. I see no way of recreating the behavior of the packer in giving the folder's name instead when selecting multiple files. Which is quite a blow, because it's useful many times. I guess I can't use the same thing as a hotkey?
Code: Select all
TOTALCMD#BAR#DATA
%commander_path%\plugins\Total7zip\7zg.exe
a "%O.zip" %P%S
wcmicons.dll,34
-1
It's mostly what I want. It'll always have the name of the first file though. I see no way of recreating the behavior of the packer in giving the folder's name instead when selecting multiple files. Which is quite a blow, because it's useful many times. I guess I can't use the same thing as a hotkey?
That's good to know. But I still don't how the shortcut does it. Based on that I would have gotten one step forward. I found shortcuts faster/better for common tasks anyway.tuska wrote:With CTRL + Click on the button ("cm_PackFiles") you can compress in the same folder.
Regards
Karl
Here's a PowerShell script you might find useful:
Code: Select all
<#
Save as TC_Packer.ps1
Put 7zg.exe and 7z.dll in the script folder
Call from TC with adjusted path:
Command:
powershell.exe
Parameter:
-NonInteractive -NoLogo -WindowStyle hidden -NoProfile -ExecutionPolicy remotesigned -Command "&{&'C:\PathToScript\TC_Packer.ps1' -FileList '%L' -SourceFolder '%P' -DestFolder '%T' -PackToSource}"
Check "Run minimized"
Remove -PackToSource to create the archive in the destination panel
#>
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$FileList,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$SourceFolder,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$DestFolder,
[switch]$PackToSource
)
$exe7zip = "$PSScriptRoot\7zg.exe"
[array]$filePaths = Get-Content -Path $FileList
if ($PackToSource)
{
$destArchive = $SourceFolder
}
else
{
$destArchive = $DestFolder
}
if ($filePaths.count -eq 1)
{
$fileNameNoExt = $(Get-Item -Path $filePaths[0]).BaseName
$args7zip = "a `"$destArchive$fileNameNoExt.zip`" @`"$FileList`""
}
else
{
$SourceFolderName = Split-Path -Leaf -Path $SourceFolder
$args7zip = "a `"$destArchive$SourceFolderName.zip`" @`"$FileList`""
}
Start-Process -FilePath $exe7zip -ArgumentList $args7zip
Works here with this test file:
TC 8.52a x86, Win10 x64 Ger/Eng
Could you give me some more details?
Code: Select all
File1_БЖ.txt
Could you give me some more details?
Now I could reproduce it.
Change the parameter from to
Change the parameter from
Code: Select all
... -FileList '%L' ...
Code: Select all
... -FileList '%UL' ...
Hmm I can edit my first post for some reason...
This should work:
This should work:
Code: Select all
<#
Save as TC_Packer.ps1
Put 7zg.exe and 7z.dll in the script folder
Call from TC with adjusted path:
Command:
powershell.exe
Parameter:
-NonInteractive -NoLogo -WindowStyle hidden -NoProfile -ExecutionPolicy remotesigned -Command "&{&'C:\PathToScript\TC_Packer.ps1' -FileList '%UL' -SourceFolder '%P' -DestFolder '%T' -PackToSource}"
Check "Run minimized"
Remove -PackToSource to create the archive in the destination panel
#>
param(
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$FileList,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$SourceFolder,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$DestFolder,
[switch]$PackToSource
)
$exe7zip = "$PSScriptRoot\7zg.exe"
[array]$filePaths = Get-Content -Path $FileList
if ($PackToSource)
{
$destArchive = $SourceFolder
}
else
{
$destArchive = $DestFolder
}
if ($filePaths.count -eq 1)
{
$fileNameNoExt = $(Get-Item -LiteralPath $filePaths[0]).BaseName
$args7zip = "a `"$destArchive$fileNameNoExt.zip`" @`"$FileList`""
}
else
{
$SourceFolderName = Split-Path -Leaf -Path $SourceFolder
$args7zip = "a `"$destArchive$SourceFolderName.zip`" @`"$FileList`""
}
Start-Process -FilePath $exe7zip -ArgumentList $args7zip