Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

[Issue] FileExist() never returns an empty string

  • Please log in to reply
1 reply to this topic
  • Moderators
  • 638 posts
  • Last active: Sep 06 2015 01:51 PM
  • Joined: 10 May 2011

FileExist() returns always 'D' if D:\FireFox\Profile\Default\Cache is empty (hidden files are shown to make sure it's empty)

CachePattern := "D:\FireFox\Profile\Default\Cache\*.*"
MsgBox,4160,, % FileExist(CachePattern)

Can anybody confirm this behavior?

FileExist(FilePattern): Returns a blank value (empty string) if FilePattern does not exist (FilePattern is assumed to be in A_WorkingDir if an absolute path isn't specified). Otherwise, it returns the attribute string (a subset of "RASHNDOCT") of the first matching file or folder. If the file has no attributes (rare), "X" is returned. FilePattern may be the exact name of a file or folder, or it may contain wildcards (* or ?). Since an empty string is seen as "false", the function's return value can always be used as a quasi-boolean value. For example, the statement if FileExist("C:\My File.txt") would be true if the file exists and false otherwise. Similarly, the statement if InStr(FileExist("C:\My Folder"), "D") would be true only if the file exists and is a directory.

All questions & answers are related to AHK x64 Unicode


  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
✓  Best Answer

This is by design.  Similarly, if you run dir in the directory, it will show you that it actually contains two directories - "." and "..".


You can use a file loop instead, as it filters out the "." and ".." entries.