Page 1 of 1

$(FullPathRight)

Posted: 15 Apr 2007, 11:01
by skwoz
I have a simple problem. I do have a difference tool wich takes direkctories as arguments. It cannot swallow directories ending with
"\". If I need to compare "C:\Prgram Files" with "D:\Program Files" and I use customizeed user menu it makes something like:
diff "C:\Prgram Files\" "D:\Program Files\"
How can I omit the "\" at the end of each argument???

Thanx
Frank

Posted: 15 Apr 2007, 13:03
by th.
Here's a little VBScript to get rid of the trailing "\":

Code: Select all

Set objArgs = WScript.Arguments
Verz1=objArgs(0)
if right(Verz1,1)="\" and right(Verz1,2)<>":\" then Verz1=left(Verz1,len(Verz1)-1)
Verz2=objArgs(1)
if right(Verz2,1)="\" and right(Verz2,2)<>":\" then Verz2=left(Verz2,len(Verz2)-1)
Set sh = WScript.CreateObject("WScript.Shell")
sh.Run "diff """ & Verz1 & """ """ & Verz2 & """"
Save it as e.g. diff.vbs and use it in AS as the user menu command.
Set the path to your compare tool in the last line according to your needs.

Thomas

Posted: 15 Apr 2007, 13:10
by Jan Rysavy
NICE!

Posted: 15 Apr 2007, 13:33
by Guest
You can replace:
if right(Verz1,1)="\" and right(Verz1,2)<>":\" then and
if right(Verz2,1)="\" and right(Verz2,2)<>":\" then

with:
If Verz1 Like "*[!:]\" Then and
If Verz2 Like "*[!:]\" Then

to make it faster.

Posted: 15 Apr 2007, 20:01
by SvA
You may try to add a dot at the end of the path and forget about the script.
i.e "$(FullPathRight)." to get "D:\Program Files\."

Posted: 16 Apr 2007, 18:05
by skwoz
Thanx a lot for the dot-tip! Perfect! It works perfectly