Page 1 of 1

User menu and Percent signs

Posted: 03 Apr 2017, 16:26
by mdruiter
Executing a user menu command (that uses Execute through shell) on some files did not work. Nothing happened... :(

It turns out this is caused by a filename containing a percent character (%). Salamander just replaces $(FullName) by the filename and puts that in the batch file it executes. But CMD interprets percent characters as special: it needs doubling them (%%) to work.
Can Salamander do just that? :idea:

Re: User menu and Percent signs

Posted: 22 May 2017, 09:47
by tukanos
mdruiter wrote:Executing a user menu command (that uses Execute through shell) on some files did not work. Nothing happened... :(

It turns out this is caused by a filename containing a percent character (%). Salamander just replaces $(FullName) by the filename and puts that in the batch file it executes. But CMD interprets percent characters as special: it needs doubling them (%%) to work.
Can Salamander do just that? :idea:
It is generally it is a bad idea to have '%' in your filename in windows based environment. I can understand that sometimes there is no other way, but if you can, avoid it.

Next to actually help you :).

I don't have access to the Salamander's code so I can only guess here. What Salamander apparently does is use CALL inside the command prompt to call any batch file - and it consumes the '%' the same way as CMD does so you need to double the double => alias quadruple it!

For more see the picture:
Running a batch file that contains a percentage sign
Running a batch file that contains a percentage sign
how_run_files_with_percentage_sign.jpg (157.89 KiB) Viewed 5970 times
P.S. I have made a obvious mistake in the batch file (SET for the filename contains only one % to show what happens. The reason why you have to use two %% is that one serves as a holder for the second one). The mistake can be fixed, as you already mentioned, doubling the %% inside the batch file.