Can I make a button to run the cmd for all selected files?

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2avada
I realized that the reason why it does not work with quotes around the path to the editor is that the Start command then thinks that it is the Title of the program, so a title needs to be added to make it work like here:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\* ((echo DO NOT MARK DIRECTORIES!) && (echo.) && pause) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do start "BEncode Editor" "E:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe" "%%n"
wcmicons.dll,28
Open all selected files in notepad at the same time

1
-1
The second button that uses the call command ind stead of the start command should work as it was:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\* ((echo DO NOT MARK DIRECTORIES!) && (echo.) && pause) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do call "E:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe" "%%n"
wcmicons.dll,28
Open all selected files in notepad one after another

1
-1
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

avada wrote:
isidro wrote:if there are spaces on either path or filename you will need to enclose all in ""
You may try first putting and renaming editor in a simpler way (with no spaces/strange chars on name or path) (ie: C:\UT\myeditor.exe)
I know but quotes don't help. And renaming/moving files is not viable, even though it works that way.
With TCBL, you can define into the ini file some "script" and use them from TC.To call an editor for all selected regular files.
inside tcbl.ini (same folder as tool)

Code: Select all

[BEdit]
ini=q
pre=set BEdit="E:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe"
cmd=%BEdit% "$f"

And inside Total Commander

Code: Select all

command=<path to>\tcbl.exe
parametters=-i %L BEdit
icon File: <path to BEncode Editor>
avada
Senior Member
Senior Member
Posts: 217
Joined: 2007-10-05, 06:24 UTC

Post by *avada »

petermad wrote:2avada
I realized that the reason why it does not work with quotes around the path to the editor is that the Start command then thinks that it is the Title of the program, so a title needs to be added to make it work like here:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\* ((echo DO NOT MARK DIRECTORIES!) && (echo.) && pause) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do start "BEncode Editor" "E:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe" "%%n"
wcmicons.dll,28
Open all selected files in notepad at the same time

1
-1
The second button that uses the call command ind stead of the start command should work as it was:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\* ((echo DO NOT MARK DIRECTORIES!) && (echo.) && pause) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do call "E:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe" "%%n"
wcmicons.dll,28
Open all selected files in notepad one after another

1
-1
It still doesn't seem to work.
There seem to be issues with the text you pasted. But even after fixing it it doesn't work:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\* ((echo DO NOT MARK DIRECTORIES!) && (echo.) && pause) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WF`) do start "BEncode Editor" "e:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe" "%%n"
wcmicons.dll,28
Open all selected files in notepad at the same time

1
-1

nsp wrote:
avada wrote:
isidro wrote:if there are spaces on either path or filename you will need to enclose all in ""
You may try first putting and renaming editor in a simpler way (with no spaces/strange chars on name or path) (ie: C:\UT\myeditor.exe)
I know but quotes don't help. And renaming/moving files is not viable, even though it works that way.
With TCBL, you can define into the ini file some "script" and use them from TC.To call an editor for all selected regular files.
inside tcbl.ini (same folder as tool)

Code: Select all

[BEdit]
ini=q
pre=set BEdit="E:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe"
cmd=%BEdit% "$f"

And inside Total Commander

Code: Select all

command=<path to>\tcbl.exe
parametters=-i %L BEdit
icon File: <path to BEncode Editor>
I took a look at TCBL. It seemed a tad complicated. At first I thought it would be a plugin. But it's an external program with it's own separate configuration. It seemed a tad complicated. But it looks like I'll need to start experimenting with it.
Windows 10
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2avada
You are right that the pasting of "alkalmazások - telepítők" went wrong.

I downloaded two versions of "BEncode Editor.exe" from https://sites.google.com/site/ultimasites/bencode-editor :
[v0.6.1.0] Unicode
[v0.6.1.0] ANSI

If I use the first one (Unicode version) the button works fine, but if I use the second one (ANSI version), the button fails if the path to the editor or the path to the selected file contains for example the ő character.

So maybe you are using an ANSI version of "BEncode Editor.exe" - in that case try the Unicode version in stead.

The button also works with [v0.7.1.0] x64 and [v0.7.1.0] Unicode
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
avada
Senior Member
Senior Member
Posts: 217
Joined: 2007-10-05, 06:24 UTC

Post by *avada »

petermad wrote:2avada
You are right that the pasting of "alkalmazások - telepítők" went wrong.

I downloaded two versions of "BEncode Editor.exe" from https://sites.google.com/site/ultimasites/bencode-editor :
[v0.6.1.0] Unicode
[v0.6.1.0] ANSI

If I use the first one (Unicode version) the button works fine, but if I use the second one (ANSI version), the button fails if the path to the editor or the path to the selected file contains for example the ő character.

So maybe you are using an ANSI version of "BEncode Editor.exe" - in that case try the Unicode version in stead.

The button also works with [v0.7.1.0] x64 and [v0.7.1.0] Unicode
I checked the version but it doesn't work with either. No clue what might be wrong
You are right that the pasting of "alkalmazások - telepítők" went wrong.
Also the "" characters, right? I have no clue what might be wrong.
Windows 10
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

I have no clue what might be wrong
Me neither, here is what I did:

1. I made a directory: "e:\alkalmazások - telepítők\Bittorrent\bencode\"
2. I put the v0.6.1.0 Unicode version of "BEncode Editor.exe" in it
3. I use the button:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\* ((echo DO NOT MARK DIRECTORIES!) && (echo.) && pause) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WL`) do start "BEncode Editor" "e:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe" "%%n"
wcmicons.dll,28
Open all selected files with BEncode Editor at the same time

1
-1
4. I mark a couple of text files and click the button
5. I see something like this: http://madsenworld.dk/tcmd/bencode.png - which to me shows that the editor launches and open the file alright - the error in line 2 is because I don't have a bittorrent script file to test with.

I have tested this under Windows 7 and 10

What happens if you try? - nothing? - or do you get any error messages, and if so, what are they?
Last edited by petermad on 2018-04-15, 12:52 UTC, edited 1 time in total.
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

There seem to be issues with the text you pasted. But even after fixing it it doesn't work
Actually - if you copy this:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\* ((echo DO NOT MARK DIRECTORIES!) && (echo.) && pause) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WL`) do start "BEncode Editor" "e:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe" "%%n"
wcmicons.dll,28
Open all selected files with BEncode Editor at the same time

1
-1
and paste it to the buttonbar (right-click buttonbar, choose Paste) - then TC automatically inserts it correctly (because of the  BOM marker)
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
avada
Senior Member
Senior Member
Posts: 217
Joined: 2007-10-05, 06:24 UTC

Post by *avada »

petermad wrote:
I have no clue what might be wrong
Me neither, here is what I did:

1. I made a directory: "e:\alkalmazások - telepítők\Bittorrent\bencode"
2. I put the v0.6.1.0 Unicode version of "BEncode Editor.exe" in it
3. I use the button:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\* ((echo DO NOT MARK DIRECTORIES!) && (echo.) && pause) else chcp 65001 && %%COMSPEC%% /C for /F "usebackq delims=" %%n in (`type %WL`) do start "BEncode Editor" "e:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe" "%%n"
wcmicons.dll,28
Open all selected files with BEncode Editor at the same time

1
-1
4. I mark a couple of text files and click the button
5. I see something like this: http://madsenworld.dk/tcmd/bencode.png - which to me shows that the editor launches and open the file alright - the error in line 2 is because I don't have a bittorrent script file to test with.

I have tested this under Windows 7 and 10

What happens if you try? - nothing? - or do you get any error messages, and if so, what are they?
Okay. So I did the same thing, but nothing happens. If the timing is right I see cmd.exe and conhost.exe appearing in Process Explorer, and immediately exiting, so I can't check the command that started them.
Windows 10
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2avada

OK - to rule out some causes of error try the button below, but on files that has ONLY English characters in the file name and path:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\* ((echo DO NOT MARK DIRECTORIES!) && (echo.) && pause) else for %%n in (%L) do start "BEncode Editor" "e:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe" "%%n"
wcmicons.dll,28
Open all selected files with BEncode Editor at the same time

1
-1
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
avada
Senior Member
Senior Member
Posts: 217
Joined: 2007-10-05, 06:24 UTC

Post by *avada »

petermad wrote:2avada

OK - to rule out some causes of error try the button below, but on files that has ONLY English characters in the file name and path:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\* ((echo DO NOT MARK DIRECTORIES!) && (echo.) && pause) else for %%n in (%L) do start "BEncode Editor" "e:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe" "%%n"
wcmicons.dll,28
Open all selected files with BEncode Editor at the same time

1
-1
Doesn't really work. I get one instance opened with some temp file. eg.:

Code: Select all

[18:18:49] [BDecode] Start: "C:\IDEIGLENES\CMDC044.tmp"
[18:18:49] [ERROR] Failed to decode the data
Windows 10
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

I get one instance opened with some temp file.
You are right, I removed too much code.

Try this - still only with filenames with all english caracters:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\* ((echo DO NOT MARK DIRECTORIES!) && (echo.) && pause) else  for /F "usebackq delims=" %%n in (`type %L`) do start "BEncode Editor" "e:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe" "%%n"
wcmicons.dll,28
Open all selected files with BEncode Editor at the same time

1
-1
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
avada
Senior Member
Senior Member
Posts: 217
Joined: 2007-10-05, 06:24 UTC

Post by *avada »

petermad wrote:
I get one instance opened with some temp file.
You are right, I removed too much code.

Try this - still only with filenames with all english caracters:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
if exist %S1\* ((echo DO NOT MARK DIRECTORIES!) && (echo.) && pause) else  for /F "usebackq delims=" %%n in (`type %L`) do start "BEncode Editor" "e:\alkalmazások - telepítők\Bittorrent\bencode\BEncode Editor.exe" "%%n"
wcmicons.dll,28
Open all selected files with BEncode Editor at the same time

1
-1
I figured out what the issue is. I just noticed that there's a chcp in the code, and I vaguely remember that 65001 didn't work for batch files (and I had to use 1250) because of god knows what stupid windows issue.

After making the change the files are opened properly with the program.
Windows 10
Post Reply