본문 바로가기
Programming/AutoHotKey

[AHK] SplitPath

by NAMP 2015. 4. 8.

# SplitPath


http://www.autohotkey.com/docs/commands/SplitPath.htm




파일명 또는 URL 에서 이름, 디렉토리, 확장자, 드리아브로 분리합니다. 


SplitPath, InputVar [, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive]



# 예제


FullFileName = C:\My Documents\Address List.txt
   
; To fetch only the bare filename from the above:
SplitPath, FullFileName, name

; To fetch only its directory:
SplitPath, FullFileName,, dir

; To fetch all info:
SplitPath, FullFileName, name, dir, ext, name_no_ext, drive
   
; The above will set the variables as follows:
; name = Address List.txt
; dir = C:\My Documents
; ext = txt
; name_no_ext = Address List
; drive = C:



GUI 를 만들고, drag drop 으로 파일을 넣을 때


해당 경로를 확인하는 코드입니다. 


#SingleInstance,Force


Gui, Add, Text, vPathT, Path:

Gui, Add, Edit, vSelFolder ys w300 +ReadOnly ; ys : Start a new column within this section http://www.autohotkey.com/docs/commands/Gui.htm

Gui, Show

return


GuiClose:  ; Indicate that the script should exit automatically when the window is closed.

ExitApp


GuiDropFiles:

Loop, parse, A_GuiEvent, `n

{

SplitPath, A_LoopField,, dir

MsgBox, %dir%

}



return










댓글