tony01 Posted May 20, 2007 Share Posted May 20, 2007 Hi everybody: This is the situation : I have many paths and I want to identify which ones are folders, All the paths already exists. Example: c:\@---- BOOKS ----\Formulas.and.Functions.With.Microsoft.Excel.003 c:\@---- BOOKS ----\Microsoft.Excel.sol C:\Program Files\XP Repair Pro 2007\XPRepairPro.exe The first, and the second one are folders, the last one is a file. Is there an Autoit Function or script to know if the path is a folder? Thanks Rudolph. Link to comment Share on other sites More sharing options...
Somerset Posted May 20, 2007 Share Posted May 20, 2007 FileGetAttrib Link to comment Share on other sites More sharing options...
jvanegmond Posted May 20, 2007 Share Posted May 20, 2007 If PathIsDir("C:\") Then MsgBox(0, "", "C:\ is a dir") Else MsgBox(0, "", "C:\ is a file") EndIf If PathIsDir("C:\Windows\Explorer.exe") Then MsgBox(0, "", "C:\Windows\Explorer.exe is a dir") Else MsgBox(0, "", "C:\Windows\Explorer.exe is a file") EndIf Func PathIsDir($s_Path) ; if the path entered is a directory, it returns a number bigger then zero. If it is not it returns 0. $s_Attrib = FileGetAttrib($s_Path) Return StringInStr($s_Attrib,"D",1) EndFunc github.com/jvanegmond Link to comment Share on other sites More sharing options...
Somerset Posted May 20, 2007 Share Posted May 20, 2007 (edited) If PathIsDir("C:\") Then MsgBox(0, "", "C:\ is a dir") Else MsgBox(0, "", "C:\ is a file") EndIf If PathIsDir("C:\Windows\Explorer.exe") Then MsgBox(0, "", "C:\Windows\Explorer.exe is a dir") Else MsgBox(0, "", "C:\Windows\Explorer.exe is a file") EndIf Func PathIsDir($s_Path) ; if the path entered is a directory, it returns a number bigger then zero. If it is not it returns 0. $s_Attrib = FileGetAttrib($s_Path) Return StringInStr($s_Attrib,"D",1) EndFuncwhat if their windows root directy is winnt, not windows? nitpick... Edited May 20, 2007 by beerman Link to comment Share on other sites More sharing options...
jvanegmond Posted May 20, 2007 Share Posted May 20, 2007 what if their windows root directy is winnt, not windows? nitpick...Then the function still works, nitpick. github.com/jvanegmond Link to comment Share on other sites More sharing options...
tony01 Posted May 20, 2007 Author Share Posted May 20, 2007 Thanks beerman , FileGetAttrib is working like a charm. Manadar, cool script, I modified a little bit: Dim $path = "c:\@---- BOOKS ----\Formulas.and.Functions.With.Microsoft.Excel.003" If PathIsDir($path) Then MsgBox(0, "", $path & " is a Directory") Else MsgBox(0, "", $path & " is a File") EndIf Func PathIsDir($s_Path) ; if the path entered is a directory, it returns a number bigger then zero. If it is not it returns 0. $s_Attrib = FileGetAttrib($s_Path) Return StringInStr($s_Attrib,"D",1) EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now