| View previous topic :: View next topic |
| Author |
Message |
bitcloud
Joined: 30 Oct 2008 Posts: 27
|
Posted: Fri Feb 19, 2010 5:34 am Post subject: Determining: File vs Folder? |
|
|
Is there a way to determine if a string is a file vs folder?
I need to treat folders differently to files, but an ifexist will only tell me if it exists, not whether it's a file or a folder
any ideas? |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Feb 19, 2010 5:43 am Post subject: Re: Determining: File vs Folder? |
|
|
| bitcloud wrote: | Is there a way to determine if a string is a file vs folder?
I need to treat folders differently to files, but an ifexist will only tell me if it exists, not whether it's a file or a folder
any ideas? |
Maybe use a file/folder loop? Posting some of your code may help too. |
|
| Back to top |
|
 |
bitcloud
Joined: 30 Oct 2008 Posts: 27
|
Posted: Fri Feb 19, 2010 6:00 am Post subject: |
|
|
Thanks... the file folder loop worked.
| Code: | Loop, %path%, 2 ;the 2 specifies to only loop for folders
{
msgbox This must be a folder/path
} |
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sat Feb 20, 2010 2:56 am Post subject: Re: Determining: File vs Folder? |
|
|
| bitcloud wrote: | | Is there a way to determine if a string is a file vs folder? |
Following method will return True/False if a Path is Folder/ Or not.
| Code: | MsgBox, % !! DllCall( "shlwapi\PathIsDirectoryA", Str,A_Windir )
; Or
Msgbox, % InStr( FileExist(A_WinDir), "D" ) ? 1 : 0
|
| Quote: | | I need to treat folders differently to files, but an ifexist will only tell me if it exists, not whether it's a file or a folder |
| Code: | Loop %A_Temp%\*.*, 1 ; Loop folders and files
If InStr( A_LoopFileAttrib, "D" )
MsgBox, %A_LoopFileName%`nis a Folder
Else
MsgBox, %A_LoopFileName%`nis a File |
|
|
| Back to top |
|
 |
|