Script help: using 'run' with a command switch...

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
kunkel321
Posts: 664
Joined: 10 Jun 2012 03:45
Location: Near Seattle

Script help: using 'run' with a command switch...

Post by kunkel321 »

This will probably be a no-brainer for some of you guys.
I have a popup list/button on my toolbar for ReNamer.
"Just Launch ReNamer"
run """C:\Program Files (x86)\ReNamer\ReNamer.exe";
"Preset: MIND+ZZ"
run ""C:\Program Files (x86)\ReNamer\ReNamer.exe" /preset "MIND+ZZ" " <curpath>"";
"Current Folder Name Itself"
run """C:\Program Files (x86)\ReNamer\ReNamer.exe"" <curpath>";
"All of Sellected Type of File"
run """C:\Program Files (x86)\ReNamer\ReNamer.exe"" *.<curext>";
You guys helped me write it years ago. Just now I added the second item (the preset one). It doesn't work.
Example from ReNamer manual
"ReNamer.exe" /preset "MyRules" "C:\Folder"
This command will launch a new instance of the program, will load the preset with the name "MyRules", and
will add contents of folder "C:\Folder" (depending on the default settings).
Error message
Overflow
0 \ 0
Any obvious fixes?
ste(phen|ve) kunkel
Scaling: Main monitor 125%, Secondary monitor on the right 100%
OS: Win 10. XYplorer version: Latest beta, unless specified.

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Script help: using 'run' with a command switch...

Post by highend »

Code: Select all

run """C:\Program Files (x86)\ReNamer\ReNamer.exe"" /preset ""MIND+ZZ"" ""<curpath>"""; 
These two entries aren't quoted correctly as well (or, for the second one: should be quoted for the path that can contain spaces. While it may work correctly if you'd use it for a different program it can easily break the call):

Code: Select all

run "C:\Program Files (x86)\ReNamer\ReNamer.exe"; 

Code: Select all

run """C:\Program Files (x86)\ReNamer\ReNamer.exe"" ""<curpath>"""; 
One of my scripts helped you out? Please donate via Paypal

kunkel321
Posts: 664
Joined: 10 Jun 2012 03:45
Location: Near Seattle

Re: Script help: using 'run' with a command switch...

Post by kunkel321 »

Many thanks Highend! I haven't replied yet because I'm still experimenting... Thanks though :)
ste(phen|ve) kunkel
Scaling: Main monitor 125%, Secondary monitor on the right 100%
OS: Win 10. XYplorer version: Latest beta, unless specified.

kunkel321
Posts: 664
Joined: 10 Jun 2012 03:45
Location: Near Seattle

Re: Script help: using 'run' with a command switch...

Post by kunkel321 »

Okidoky.. Back to this project. I've been on the forum for nearly four years, and I like to think of myself as a "power-user." So it's a bit embarrassing that something as basic as this eludes me... I've reinstalled ReNamer and it's in a different location. My preset (which I can call with a command switch) has also been renamed. I have a User Button. Normal left-click does this: ::run """C:\Program Files (x86)\Portables\ReNamer\ReNamer.exe"" <selitems>"; which works as expected. Right-click calls this script:

Code: Select all

"Preset:  BookNameCleaner"
  run """C:\Program Files (x86)\Portables\ReNamer\ReNamer.exe"" /preset ""BookNameCleaner"" ""<selitems>""";
"Current Folder Name Itself"
  run """C:\Program Files (x86)\Portables\ReNamer\ReNamer.exe"" ""<curpath>"""; 
"All of Sellected Type of File"
  run """C:\Program Files (x86)\Portables\ReNamer\ReNamer.exe"" *.<curext>"; 
At this point I'm not even worried about the last two.
Highend had previous indicated: run """C:\Program Files (x86)\ReNamer\ReNamer.exe"" /preset ""MIND+ZZ"" ""<curpath>"""; which, I believe, did work. I realized after posting, that I actually want to use <selitems>, not current path. I modeled my new one (top of code block, above) after Highend's. It does open the preset correctly, but it's apparently not "seeing" the selected items. Do I have a typo in there?

A more general question: Is there a tutorial somewhere that focuses on when/where/why to use all those quotation marks? I mean that one line has like 14 ! :eh:
ste(phen|ve) kunkel
Scaling: Main monitor 125%, Secondary monitor on the right 100%
OS: Win 10. XYplorer version: Latest beta, unless specified.

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Script help: using 'run' with a command switch...

Post by highend »

<selitems> already returns quoted items (space separated). So doubling the quotes around them isn't a good idea^^ because you'd get (resolved):

Code: Select all

"C:\Program Files (x86)\Portables\ReNamer\ReNamer.exe" /preset "BookNameCleaner" ""item 1" "item 2""
and that's something not all programs can work with. Most of them don't.

Code: Select all

run """C:\Program Files (x86)\Portables\ReNamer\ReNamer.exe"" /preset BookNameCleaner <selitems>";
Would be the right way. If a preset name can contain spaces you need to quote it again like:

Code: Select all

run """C:\Program Files (x86)\Portables\ReNamer\ReNamer.exe"" /preset ""Book Name Cleaner"" <selitems>";
Last words: NEVER put your portables in one of the system folders (in this case Program Files (x86))! Bad idea. You need admin rights to write to this folder and it's subfolders and if you start a portable from there without admin rights, saving settings will be real problem.
One of my scripts helped you out? Please donate via Paypal

Post Reply