Script help - path names as arguements

Discuss and share scripts and script files...
Post Reply
jacksonmacd
Posts: 32
Joined: 07 Dec 2011 05:33

Script help - path names as arguements

Post by jacksonmacd »

Looking for help with the correct syntax for a command. Trying to pass the pathname for left and right pane to an external program. I've put msg statements into the script for debugging, and they appear to return the correct (expected) values. Also hard-wired some example pathnames into the script, and that works properly. The last line of my script fails -- it launches the program (a file-sync program that needs two pathnames as arguments), but the incorrect file folders are selected.


$path = tab("get", "path");
$pathi = get("path", i);
msg $path;
msg $pathi;
msg run '"C:\Program Files\FreeFileSync\FreeFileSync.exe" -leftdir $path -rightdir $pathi';

run '"C:\Program Files\FreeFileSync\FreeFileSync.exe" -leftdir "C:\Program Files\Collage Maker" -rightdir "E:\AUDIBLE\Podcasts\"';

run '"C:\Program Files\FreeFileSync\FreeFileSync.exe" -leftdir "$path" -rightdir "$pathi"'



As mentioned, the third msg line displays correct values, the first "run" command (hardwired pathnames) works properly, but the second one fails. Same results WITH or WITHOUT the quotations around the $path and $pathi variables.

Thanks in advance.

FluxTorpedoe
Posts: 855
Joined: 05 Oct 2011 13:15

Re: Script help - path names as arguements

Post by FluxTorpedoe »

Hi'
This line should suffice:

Code: Select all

run "C:\Program Files\FreeFileSync\FreeFileSync.exe" "<get path a>" "<get path i>";
- - - - - - - - -
As for the reason of your problem, I think it comes from using command-line arguments outside quotes. So if you're sure about your command-line, it should work if rewritten as:

Code: Select all

run """C:\Program Files\FreeFileSync\FreeFileSync.exe"" -leftdir ""$path"" -rightdir ""$pathi""";
or

Code: Select all

run "C:\Program Files\FreeFileSync\FreeFileSync.exe" "-leftdir" "$path" "-rightdir" "$pathi";
Hope this helps, 8)
Flux

jacksonmacd
Posts: 32
Joined: 07 Dec 2011 05:33

Re: Script help - path names as arguements

Post by jacksonmacd »

Excellent!

The single-line function did not work. There was an error dialog from the external program that the folder could not be found. However, your first version replacement for my line worked perfectly. Did not try the second one...

Dunno if it's just me, but I found the syntax regarding quotation marks to be extremely frustrating. Probably spent two hours in three different sessions, trying every combination I could think of. Obviously missed a few!!

Thanks again for your input and solution.

FluxTorpedoe
Posts: 855
Joined: 05 Oct 2011 13:15

Re: Script help - path names as arguements

Post by FluxTorpedoe »

jacksonmacd wrote:The single-line function did not work. There was an error dialog from the external program that the folder could not be found.
Oh... It's been a while since I used FreeFileSync, they must have changed their command-line options.
- - -
• A quick explanation about the quotes here: I put the whole argument of run inside single-quotes:
run "argument";
- but as part of the argument, there are several elements (paths) that may contain spaces, so each of them need to be quoted:
"path"
- but since they're themselves inside the quotes of the run argument, they need to be double-quoted instead of single-quoted:
run " ""apppath"" command ""otherpath"" ";

cinfwyx
Posts: 1
Joined: 23 Feb 2014 15:37

Re: Script help - path names as arguements

Post by cinfwyx »

My English is not good enough.
I use XYplorer and FreeFileSync some time.By use the customize button,I put the 2 Program together, something which may be just what you want.

Code: Select all

sel;$str11=quote(get("path",1));$str21=quote(get("path",2));openwith """<xypath>\FreeFileSync\Bin\FreeFileSync_Win32.exe"" -leftdir $str11 -rightdir $str21", s;

Of course, my FreeFileSync folder on the inside XYplorer's. FreeFileSync is a green software, So,direct Copy it to there,or change the Sentence to fit you.
the script in Button's Editor,only written a single line.

I like this use, in good condition.

Post Reply