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 

Problem with IfExist Command and file extensions

 
Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
olle



Joined: 11 Aug 2009
Posts: 1

PostPosted: Tue Aug 11, 2009 7:49 pm    Post subject: Problem with IfExist Command and file extensions Reply with quote

Just now I was testing a script that used the IfExist command. I was using a line exactly like the one in the help file only with the extension .MSI (IfExist, D:\Docs\*.msi).

I had an .msi file in the directory that met the criteria and the test worked.

However, when I renamed the file and added a 1 to the end of the extension (e.g. test.msi1), the file was still found even though I was declaring to only look for .MSI

I renamed the file .MSI_TEST and it was still found. No matter what the extension was, as long as it started with .MSI the file was found.

The command seems to be actually behaving like this: IfExist, D:\Docs\*.msi*

I'm using AHK Ver: 1.0.48.03

AHK is great! Thought you would appreciate the info. Please have a look as time permits. Thanks.
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 4652
Location: AHK Forum

PostPosted: Tue Aug 11, 2009 9:03 pm    Post subject: Reply with quote

This is odd Confused

I could not find anything on FindFirstFile MSDN.

It looks like it will work only if * in file patterns is positioned 7 characters++ after last \
Code:

So for a file C:\AutoHotkey.exe1
IfExist,C:\AutoHo*.exe ;will find it and
IfExist,C:\AutoHot*.exe ;will not find it

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
haichen



Joined: 05 Feb 2007
Posts: 189
Location: Osnabrück, Germany

PostPosted: Tue Aug 11, 2009 9:20 pm    Post subject: Reply with quote

Code:
file test.msi1
ifexist , *.msi1 ;found only this but no .msi


file test.msi1bla
ifexist , *.msi1 ; not found
ifexist , *.msi ; found the file


Strange.
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7295
Location: Australia

PostPosted: Sun Aug 23, 2009 1:18 pm    Post subject: Reply with quote

See 8.3 filename. A file named "test.msiblablabla" may in fact have an associated short filename "TEST~1.MSI", in which case it would be matched by *.msi.
Code:
Loop *.msi
    MsgBox % A_LoopFileShortName "`n" A_LoopFileName "`n" A_LoopFileExt
One possible solution:
Code:
exist := false
Loop *.msi
    if A_LoopFileExt = msi  ; Uses extension as seen in long filename.
    {
        exist := true
        break
    }
MsgBox % exist
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Bug Reports 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