Hi there.
this is my first steps working with applescript. im trying to write a script which organizes files in a folder depending on file type (name extenstion).
here is what i got sofar:
tell application "Finder"
set imageType to {"jpg", "tiff", "psd"}
set audioType to {"mp3", "wav"}
set videoType to {"mov", "avi", "wmv", "mpeg", "mpg"}
-- other filetypes to be added here...
set allFiles to every document file of folder "example"
repeat with oneFile in allFiles
try
set fileType to name extension of oneFile
if imageType contains filetype then
move oneFile to folder "Images" in folder "example"
else if audioTypes contains filetype then
move oneFile to folder "Audio" in folder "example"
else if videoTypes contains filetype then
move oneFile to folder "Video" in folder "example"
end if
end try
end repeat
end tell
Is there a way to optimze this code usnig records or lists so i need only one search query and get the destination folder?