Page 1 of 1

New parameter '%Selected' for repeated command execution

Posted: 2012-05-05, 18:47 UTC
by CopyCats
I'd like to see a new magic parameter "%Selected" that can be used in the command line box (and possibly in button definitions?).

It would stand for "each file that is currently selected".

The magic is that when Total Commander sees this parameter in a command, it will automatically repeat that command for each file that is currently selected! :D

For example, if I have selected 5 files, and I type in the command line box: "Notepad %Selected", then Total Commander will pass this batch of commands to the OS:

[face=courier]Notepad <selected_file_1>
Notepad <selected_file_2>
Notepad <selected_file_3>
Notepad <selected_file_4>
Notepad <selected_file_5>
[/face]

Additional related new parameters could be:
%SelectedStop%, where each command must complete and exit before the next is started;
%SelectedPath%, where not just the filename but its full path is passed, and
%SelectedPathStop% which combines the above.

(in the logfile, each commandline that was executed would have to be recorded individually, so you can check what you did wrong when things go awry :lol:)

Of course, the actual name of this new parameter doesn't matter; '%X' would be just fine too.

P.S. a different but related idea: it would be nice if we could somehow use the button bar parameters (%N, %S, etc) in the command line box too. The benefit would be that you could repeat such commands for different files without having to edit the command line at all.

Posted: 2012-05-05, 21:07 UTC
by sqa_wizard
... it will automatically repeat that command for each file that is currently selected!
Try List to MultiInstance (a TC utility) for this purpose.

Posted: 2012-05-05, 21:57 UTC
by Hacker
CopyCats,
Or use RunOnAllCores.ahk.

Roman

Posted: 2012-05-06, 06:59 UTC
by CopyCats
Thanks guys, but I suggested it because I feel that TC should have this functionality built-in.

Posted: 2012-05-07, 18:13 UTC
by Balderstrom
TC already can do this, with %UL, %L, or %WL

The problems are:
1) TC doesn't have consistent quoting mechanism and doesn't allow one to force quoting around file names.
2) Batch files don't handle UTF-16 Files at all.
3) Batch files don't handle UTF-8 Files that have various unicode characters in file names.

One could possibly use PowerShell, but most TC users are more familiar with batch (cmd).

If your files don't have UTF/Unicode characters then a command button:
Command: cmd.exe /k tcRunFile.cmd
Parameters: notepad.exe %L

Code: Select all

FOR /F "usebackq delims=" %%F IN ("%~2") DO CALL:RunFile "%~1" "%%~F"
GOTO:EOF
:RunFile
START "" %1 %2
Personally, I just use AHK for most intents and purposes. The batch command line is not dependable enough.

You'll likely find suggestions for "features" that already have a plugin/workaround wont be implemented.

Search the board for "built in" or "built-in", lots of suggestions by users that feel that feature-x should be native/built-in that already has a workaround/script or plugin.

Granted I find it amusing that so many users refuse to use the provided workaround/script when people attempt to help. And instead just go without it entirely.

Posted: 2012-07-02, 14:40 UTC
by buzzlightyear
Balderstrom wrote:Granted I find it amusing that so many users refuse to use the provided workaround/script when people attempt to help. And instead just go without it entirely.
Perhaps because Win32 console apps, including scripts, open a black console window which closes immediately (leaving the average user with the impression something has gone wrong or something that they cannot control was going on) or simply look alienating for the non-professional user?

Have you noticed how many shareware apps are being offered (and bought!) that do nothing else than wrapping existing command line apps with a GUI? Example: Just try to count the numerous utilities that translate ip addresses to names or vice versa LOL

IMO a better approach is to use external apps that run in the Win32 subsystem. For example, use 7zg.exe instead of 7z.exe.
Or use tools like run.exe that completely hide the console window.