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 

Check file extensions

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



Joined: 08 Dec 2007
Posts: 9

PostPosted: Thu Dec 13, 2007 5:07 am    Post subject: Check file extensions Reply with quote

I'm trying to loop through files and check their extensions to see if they are images, if they are, I want to add them to a list.

This is what I'm trying, but Autohotkey won't let me. it gives me this error
Quote:

Error: The following variable name contains an illegal character: "slctemple.jpg"
...
105:StringRight, ext,%A_LoopFileName%, 4
...


Code:

loop,%imgPath%\*,,0
{
   StringRight, ext, %A_LoopFileName%, 4 ;get extension from filename
   StringLower, ext, ext
   if ext in .jpg, jpeg, .bmp, .gif, .png, .tif
   {
      path%num% = %A_LoopFileFullPath%
      num++
   }
}


any ideas?
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1249
Location: USA

PostPosted: Thu Dec 13, 2007 5:09 am    Post subject: Reply with quote

remove the % from the StringTrim Command ....also need to remove the spaces after the commas in the if ext in line.
_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
deletarus



Joined: 08 Dec 2007
Posts: 9

PostPosted: Thu Dec 13, 2007 6:03 am    Post subject: Reply with quote

Good call, thanks.
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 1186
Location: switzerland

PostPosted: Thu Dec 13, 2007 8:11 am    Post subject: Reply with quote

can use also the command splitpath , get ext as= rm ram ...
SplitPath, A_LoopFileName, name, dir, ext, name_no_ext, drive
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   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