Internal file association - Using %p%o variables
Moderators: white, Hacker, petermad, Stefan2
Internal file association - Using %p%o variables
Hi
I'm trying to accomplish a simple thing - extracting a zip into containing folder with filename as folder name.
Trying to associate a verb, I saw you can only pass %1 to the program - in my case 7z x -o%1 %1.
Problem is that you cannot extract to a folder where the foldername is the same as an existing filename.
I saw there's no way to pass %P%O to internal associations...
cm_unpackfiles does not take any arguments
Is there a way to accomplish that without associating to a script (and without using a button) ?
I'm trying to accomplish a simple thing - extracting a zip into containing folder with filename as folder name.
Trying to associate a verb, I saw you can only pass %1 to the program - in my case 7z x -o%1 %1.
Problem is that you cannot extract to a folder where the foldername is the same as an existing filename.
I saw there's no way to pass %P%O to internal associations...
cm_unpackfiles does not take any arguments
Is there a way to accomplish that without associating to a script (and without using a button) ?
What will Total commander be like 10 years from now?
Tc 9.51 Final, #351732 Single, Win7x64
Tc 9.51 Final, #351732 Single, Win7x64
Re: Internal file association - Using %p%o variables
aviasd,
If I understand correctly, the usual way is Alt-F9, Delete, Alt-S, Enter. Not sure if this is what you're looking for, though.
Roman
If I understand correctly, the usual way is Alt-F9, Delete, Alt-S, Enter. Not sure if this is what you're looking for, though.
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Re: Internal file association - Using %p%o variables
Yeah, That's exactly the process I want to automate - too much typing for such an everyday scenario...
Right now I have button that does this on one click, but i was wondering how to do it with internal association so i can right click on a file and select extract to folder
Right now I have button that does this on one click, but i was wondering how to do it with internal association so i can right click on a file and select extract to folder
What will Total commander be like 10 years from now?
Tc 9.51 Final, #351732 Single, Win7x64
Tc 9.51 Final, #351732 Single, Win7x64
Re: Internal file association - Using %p%o variables
Internal association are like Windows association and unfortunately do not use TC command or fancy TC syntax... if you have 7Zip/Peazip/Winrar fully installed, you can already see in the Right Click <7zip> menu the extract you want.aviasd wrote: ↑2020-04-28, 13:39 UTC Yeah, That's exactly the process I want to automate - too much typing for such an everyday scenario...
Right now I have button that does this on one click, but i was wondering how to do it with internal association so i can right click on a file and select extract to folder
If you do not want any button, you can make a user_command and then reuse it for a hotkey or an alias.
You can also use external editor technique using tcer f4minimenu ....
if you want to process many files at once, you can use TCBL with filtering but you will have to use a dedicated ini command with filtering which fall to dedicated script..
Re: Internal file association - Using %p%o variables
I'm using TC as portable on Pcs that are clean, And I don't want to leave traces of other programsInternal association are like Windows association and unfortunately do not use TC command or fancy TC syntax... if you have 7Zip/Peazip/Winrar fully installed, you can already see in the Right Click <7zip> menu the extract you want.
This one actually looked like a good option but it seems it doesn't accept any of TC's %P %N arguments as well... Or does it? Documentation doesn't show how...You can also use external editor technique using tcer f4minimenu ....
Doesn't the use of TCBL require making a button/user_command as well?if you want to process many files at once, you can use TCBL with filtering but you will have to use a dedicated ini command with filtering which fall to dedicated script..
This seems like the best option (in case tcer doesn't support special arguments)If you do not want any button, you can make a user_command and then reuse it for a hotkey or an alias.
The reason I don't want a button is, I try to use the keyboard exclusively for actions I do all the time, and just pressing Shift+F10 and selecting that option seemed the most intuitive for me.(2-3 Keyboard presses)
Sorry if that sounds too picky..
Just for reference the command I need to run is: 7z x -y -o%P%O %P%N
What will Total commander be like 10 years from now?
Tc 9.51 Final, #351732 Single, Win7x64
Tc 9.51 Final, #351732 Single, Win7x64
Extract ZIP archive to folder with filename; em_ExtractToFolder UDC
>> Sorry if that sounds too picky..
Not at all
Example:
[em_ExtractToFolder]
; extracting a zip into folder with ZIP-filename as folder name.
; viewtopic.php?p=384429#p384429
; Usage: 7za <command> [<switches>...] <archive_name>
; x: eXtract files with full paths
; -y: assume Yes on all queries
; -o{Directory}: set Output directory
; TC params:
; %P source path\ (not need, TC works already in current active folder)
; %O filename without extension (used for foldername)
; %N filename
cmd="%Commander_Path%\TOOLs\PACKER\7za.exe"
param=x -y -o"%O" %N
; ; Note: %O needs to be quoted if archive name contains white space,
; ; %N must not, as TC do this itself. Use an leading '?' as parameter to explore that by yourself.
FAQs: User-Defined Command (UDC) (usercmd.ini) em_command
- Create own commands to use in button or to execute them by an keyboard shortcut.
viewtopic.php?p=344777#p344777
HTH?
Not at all
aviasd wrote: ↑2020-04-29, 07:56 UTC ...
....This seems like the best option (in case tcer doesn't support special arguments)If you do not want any button, you can make a user_command and then reuse it for a hotkey or an alias.
...
...
Just for reference the command I need to run is: 7z x -y -o%P%O %P%N
Example:
[em_ExtractToFolder]
; extracting a zip into folder with ZIP-filename as folder name.
; viewtopic.php?p=384429#p384429
; Usage: 7za <command> [<switches>...] <archive_name>
; x: eXtract files with full paths
; -y: assume Yes on all queries
; -o{Directory}: set Output directory
; TC params:
; %P source path\ (not need, TC works already in current active folder)
; %O filename without extension (used for foldername)
; %N filename
cmd="%Commander_Path%\TOOLs\PACKER\7za.exe"
param=x -y -o"%O" %N
; ; Note: %O needs to be quoted if archive name contains white space,
; ; %N must not, as TC do this itself. Use an leading '?' as parameter to explore that by yourself.
FAQs: User-Defined Command (UDC) (usercmd.ini) em_command
- Create own commands to use in button or to execute them by an keyboard shortcut.
viewtopic.php?p=344777#p344777
HTH?
Re: Internal file association - Using %p%o variables
2aviasd
Why not just assign a keybord shortcut to an em_command:
In your usercmd.ini file put:
[em_unzip]
cmd="pathto7zip\7z.exe"
param=x -y -o"%P%O" %P%N
and then via "Options..." -> "Misc" -> "Redefine hotkeys (keyboad remapping)" assign a hotkey to em_unzip
Why not just assign a keybord shortcut to an em_command:
In your usercmd.ini file put:
[em_unzip]
cmd="pathto7zip\7z.exe"
param=x -y -o"%P%O" %P%N
and then via "Options..." -> "Misc" -> "Redefine hotkeys (keyboad remapping)" assign a hotkey to em_unzip
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Re: Internal file association - Using %p%o variables
Thanks Guys,
By the time I read the post I already implemented my own alias: ex to a em_extractToFolder , which looks about the same as your editions, Although not as documented Stefan
But I did not give up on internal associations and created a script which I can use with internal associations variable %1.
I'm posting this as a template. Maybe it'll help someone.
By the time I read the post I already implemented my own alias: ex to a em_extractToFolder , which looks about the same as your editions, Although not as documented Stefan
But I did not give up on internal associations and created a script which I can use with internal associations variable %1.
I'm posting this as a template. Maybe it'll help someone.
Code: Select all
@echo off
::unQuoted filename
set filename=%~1
::Absolute Path
set abpath=%~f1
::Folder
set folderpath=%~dp1
::w/o ending backslash
set folderpath=%folderpath:~0,-1%
::parent folder name
call :getfoldername %folderpath%
::Just filename (no ext)
set jfilename=%~n1
::extension
set ext=%~x1
::size
set size=%~z1
goto run
:getfoldername
set foldername=%~n1
goto :EOF
:run
::run what's needed here
set output=%folderpath%\%jfilename%
if exist "%output%" set output=%output%.%random%
echo Executing.
7za x -y -o"%output%" "%filename%"
if %errorlevel% NEQ 0 pause
echo Done.
goto :EOF
What will Total commander be like 10 years from now?
Tc 9.51 Final, #351732 Single, Win7x64
Tc 9.51 Final, #351732 Single, Win7x64