Applescript: How to open files in repeat loop

So, I’m a completely newbie on this applescript thing.

What I’m trying to archive with this script that runs in a automator folder is:


If image(s) file(s) is added to this specific folder do this:

1. Create a new folder

2. Give the folder the same name as the new file

3. Move the file to the corresponding folder.


So far, the steps above I managed to archive.


The next step I want to be able to do is to open the moved file in Photoshop and run a photoshop action on it. I’ve tried “open this_file” but it doesn’t open it. Any ideas on how to solve this? I get no error messages when running it.



here's my script


---------------------------


on run {input, parameters}
tell
application "Finder"
set
mlist to every file of folder "Macintosh HD:Users:matmil:Desktop:drop" whose (name ends with ".jpg" or name ends with ".jpeg" or name ends with ".png" or name ends with ".gif")
repeat with
this_file in mlistset cur_ext to name extension of this_fileset new_name to text 1 thru -((length of cur_ext) + 2) of (name of this_file as text)
set
new_folder to make new folder with properties {name:new_name} at folder "Macintosh HD:Users:matmil:Desktop:drop"move this_file to new_foldertell application "Adobe Photoshop CC 2014"

activate

open this_file <-- Is this what I'm doing wrong?

do action “cool effects" from "cool effects folder"

end tell end repeat
end tell
return
input

end run

MacBook Pro (Retina, 13-inch, Mid 2014), OS X Yosemite (10.10.5), null

Posted on Sep 13, 2015 2:00 PM

Reply
4 replies

Sep 14, 2015 12:06 AM in response to MatrikPerg

You need some syntax upgrade and simplification to get the open statement to work.


property valid_extension : {"jpg", "jpeg", "png", "gif"}

onrun{input,parameters}

tell application "Finder"

set mlist to (every file of folder "Macintosh HD:Users:matmil:Desktop:drop" whose name extension is in valid_extension) as alias list


repeat with this_file in mlist

set cur_ext to name extension of this_file

set new_name to text 1 thru -((length of cur_ext) + 2) of (name of this_file as text)

set new_folder to make new folder with properties {name:new_name} at folder "Macintosh HD:Users:matmil:Desktop:drop"

movethis_filetonew_folder


tell application "Adobe Photoshop CC 2014"

activate

openthis_file

-- do action “cool effects" from "cool effects folder

closethis_file

end tell end repeat
end tell
return
input

end run

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript: How to open files in repeat loop

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.