Remove trailing slash from a path

Got a problem you cannot solve? Try here.
glenharvy
Posts: 167
Joined: Fri Sep 14, 2007 3:53 am

Remove trailing slash from a path

Postby glenharvy » Wed Dec 03, 2014 1:16 pm

Hi,

Given a path of say "C:\Trash\My Trash Bin\Files\", is there some easy way to remove the trailing slash?

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Remove trailing slash from a path

Postby FrancescoT » Thu Dec 04, 2014 9:15 am

Dear Glen,

you could use "Parse String" command along with "split at the last occurence of the pattern", in order to remove the last slash from a given path (if any).

Example (opy and past the InstallAware Clipboard Data below in your script) ;

Code: Select all

~InstallAware Clipboard Data~
~MessageBox~
~{2723557B-A452-45FC-83B8-E24EE96E1A1C}~
~~
~MY_NEW_PATH=$MY_NEW_PATH$~
~0~
~1~
~~
~Parse String~
~{93464BCC-07A7-466B-8B46-07645D1EDACB}~
~$MY_PATH$~
~\~
~MY_NEW_PATH~
~~
~1~
~FALSE~
~FALSE~
~Set Variable~
~{58D06FB1-EFD0-4D8F-9ECC-84BCA55E62AF}~
~MY_NEW_PATH$MYAH$MYAH$FALSE~
~~
~Set Variable~
~{84FB7472-5A15-457A-A4DB-E40C51561ECB}~
~MY_PATH$MYAH$MYAH$FALSE~
~C:\Trash\My Trash Bin\Files\~


hope this helps you.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

glenharvy
Posts: 167
Joined: Fri Sep 14, 2007 3:53 am

Re: Remove trailing slash from a path

Postby glenharvy » Thu Jun 25, 2015 3:47 pm

Would need to check first that the last character was indeed the last slash

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Remove trailing slash from a path

Postby FrancescoT » Fri Jun 26, 2015 1:01 pm

Dear Gary,

in fact it's what the code already does.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: Google [Bot] and 133 guests