Skip to content
⌘ NSIS Forum Archive

Strip filename

4 posts

ZmAn3#edited

Strip filename

Im sure this has been answered but I cant find it, I have the selectFile dialog box return
the path and filename of what file was selected as $varSelectedFile
example c:\blah\blah\yak.exe
I found a function that strips that down to just the filename but I also need one that gives me just the path with no filename from that if anyone can help me out

Thanks 🙂

EDIT: would also like to get the file name minus the extention as a var too
Animaether#
!include "FileFunc.nsh"
OutFile "text.exe"
ShowInstDetails show
Page InstFiles
Section
    StrCpy $0 "c:\some\path\with\somefile.ext"
    ${GetParent} $0 $1
    ${GetFileName} $0 $2
    ${GetBaseName} $0 $3
    ${GetFileExt} $0 $4
    DetailPrint "Input: $0"
    DetailPrint "GetParent: $1"
    DetailPrint "GetFileName: $2"
    DetailPrint "GetBaseName: $3"
    DetailPrint "GetFileExt: $4"
SectionEnd 
See chapter "E.1 File Functions Header" of the NSIS documentation (help file) for details.
ZmAn3#
Need more help please ,it appears the Charstrip does not work if the text contains _ underscores is there somthing I can do
so I have text that will always contain underscores like d_bgchk_Pasomthing_somthing.exe
and in this case I want to strip off d_bgchk_ and get the rest back

${CharStrip} "d_bgchk_" "$1" $R0
$1 would be the file name and this does not work however
${CharStrip} "d" "$1" $R0
strips the d off $1 so its anything after _

Thanks again
EDIT: nevermind should have used StrStrip lol