Skip to content
⌘ NSIS Forum Archive

remove last character if it is \

4 posts

winman2004#

remove last character if it is \

i want a code in nsis which can check for last character in a variable. If last character is / then i want to remove it.

Ex:

If $var is C:\mypath\ then i want output as only C:\mypath

if $var is C:\mypath then output is C:\mypath
jpderuiter#
You can 'abuse' the EXEDIR variable for that.
See http://nsis.sourceforge.net/Search_For_a_File (first code sample)

For a more robust solution see:
Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.
shadowpoa#
great solution

Hi,

Reading posts here about same subject I've got one of the best ways to do that.

Simple copy your var to $outdir them copy it back.

$Outdir have special a treatment to remove the slash on the end of string


Doing like this will solve your problem.

     StrCpy $OUTDIR $var
StrCpy $var $OUTDIR