Page 1 of 1
Remove trailing slash from a path
Posted: Wed Dec 03, 2014 1:16 pm
by glenharvy
Hi,
Given a path of say "C:\Trash\My Trash Bin\Files\", is there some easy way to remove the trailing slash?
Re: Remove trailing slash from a path
Posted: Thu Dec 04, 2014 9:15 am
by FrancescoT
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
Re: Remove trailing slash from a path
Posted: Thu Jun 25, 2015 3:47 pm
by glenharvy
Would need to check first that the last character was indeed the last slash
Re: Remove trailing slash from a path
Posted: Fri Jun 26, 2015 1:01 pm
by FrancescoT
Dear Gary,
in fact it's what the code already does.
Regards