 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
deletarus
Joined: 08 Dec 2007 Posts: 9
|
Posted: Thu Dec 13, 2007 5:07 am Post subject: Check file extensions |
|
|
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 |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1249 Location: USA
|
Posted: Thu Dec 13, 2007 5:09 am Post subject: |
|
|
remove the % from the StringTrim Command ....also need to remove the spaces after the commas in the if ext in line. _________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
deletarus
Joined: 08 Dec 2007 Posts: 9
|
Posted: Thu Dec 13, 2007 6:03 am Post subject: |
|
|
| Good call, thanks. |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1186 Location: switzerland
|
Posted: Thu Dec 13, 2007 8:11 am Post subject: |
|
|
can use also the command splitpath , get ext as= rm ram ...
SplitPath, A_LoopFileName, name, dir, ext, name_no_ext, drive |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|