Use of wildcards...

Can wildcards be used in AppleScript? I would like to be prompted to select a folder when files with extensions “sit”, “sitx”, and .mp3, .mp4, .md5, etc. are dropped into a folder (What I’m saying is I want to be prompted when a file .sit, .sitx, or anything else is put in this folder). I have tried “”, " ", and “*” to select this group, but it doesn’t work. Any help would be greatly appreciated. Cheers
–snip–
else if the name extension of aFile is in ¬
{“sit”, “sitx”} then
set the_folder to (choose folder with prompt “Where does this go?”)
try
move aFile to folder the_folder
end try
–snip–

Hi,

is this what you meant?

tell application “Finder”
set aFile to (choose file) as alias
if the name extension of aFile contains “sit” then
set the_folder to (choose folder with prompt “Where does this go?”)
try
move aFile to folder the_folder
end try
end if
end tell

hmm. let me clarify.

I have a folder that I want to autosort the files that are dropped into it. As it is set up now…
files with extension “a”, “b”, or “c” go to folder 1
files with extension “d”, “e”, “f”, & “g” go to folder 2
files with extension “h”, “i”, “j”, & “k” go to folder 3

I’d like to insert a command like that does the following…
“files with extension “l - z” prompt me for a folder”

so instead of having to manually put in “l”, “m”, “n”, … “z” I was hoping for to use a wildcard that would select “l - z” (i.e., everything that has not been defined yet in the script).

Thanks.

Just use an else clause without any condition:

if nameExtension is in {"a", "b", "c"} then
	move theFile to folder1
else if nameExtension is in {"d", "e", "f"} then
	move theFile to folder2
else if nameExtension is in {"g", "h", "i"} then
	move theFile to folder3
else if nameExtension is in {"j", "k"} then
	move theFile to folder4
else
	-- this will get run if none of the previous conditions are true, i.e. catch all other files
	move theFile to (choose folder with prompt "Where do you want to go today?")
end if

Thanks, that worked like a dream. I’m super new at this so please forgive me.

Ok. My script is almost ideal. However…

I would like to add a statement that distinguishes between files & folders.
Example:
if item is folder then
exit script
else
sort file by criteria xyz (see above post)

However, I can’t seem to find documentation discussing this.

Hooray! I figured it out on my own…

repeat with aFile in added_items
if class of item aFile is folder then
display dialog ¬
“A folder has been added, exiting script” buttons {“OK”} default button 1
if the button returned of the result is “OK” then
exit repeat
end if
else …