AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Determining: File vs Folder?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
bitcloud



Joined: 30 Oct 2008
Posts: 27

PostPosted: Fri Feb 19, 2010 5:34 am    Post subject: Determining: File vs Folder? Reply with quote

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
View user's profile Send private message
Guest






PostPosted: Fri Feb 19, 2010 5:43 am    Post subject: Re: Determining: File vs Folder? Reply with quote

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

PostPosted: Fri Feb 19, 2010 6:00 am    Post subject: Reply with quote

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
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Sat Feb 20, 2010 2:56 am    Post subject: Re: Determining: File vs Folder? Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group