To Whom It May Concern:
I’m pretty much at my wits end with this script. I’m simply trying to get a folder to react when a file is written to it. That’s all. As you will see in the script below, I’ve tried a number of different logic and nothing wants to play nice. I can get it to work if I manually select the image. That’s counter productive when I will be running 1000 images through this process on any given afternoon. To test this, I created a folder named Train that contains two folders inside it, a-before and b-after. All I need is when an image is written to a-before, it opens the image and manipulates it based on the actions in the script, (scale , pad and move to b-after). This works with manually selecting the image as shown. Any help would be appreciated.
I’m pretty much at my wits end with this script. I’m simply trying to get a folder to react when a file is written to it. That’s all. As you will see in the script below, I’ve tried a number of different logic and nothing wants to play nice. I can get it to work if I manually select the image. That’s counter productive when I will be running 1000 images through this process on any given afternoon. To test this, I created a folder named Train that contains two folders inside it, a-before and b-after. All I need is when an image is written to a-before, it opens the image and manipulates it based on the actions in the script, (scale , pad and move to b-after). This works with manually selecting the image as shown. Any help would be appreciated.
Code:
tell application "Finder" to set this_file to choose file without invisibles
tell application "Image Events"
launch
set this_image to open this_file
set the target_length to 800
scale this_image to size target_length
pad this_image to dimensions {800, 800}
save this_image with icon
close this_image
tell application "Finder"
move every file of folder "Mac HD:Users:facianp:Desktop:train:a-before:" to folder "Mac HD:Users:facianp:Desktop:train:b-after:"
end tell
end tell
Below are different scripts I’ve written that have failed.
--tell application "Finder" to set this_image to every file of folder "Mac HD:Users:facianp:Desktop:train:a-before:"
--tell application "Finder" to get every file of folder "Mac HD:Users:facianp:Desktop:train:a-before"
--tell application "System Events" to get items of folder "Mac HD:Users:facianp:Desktop:train:a-before:"
--tell application "Finder" to set this_image to every file of folder "Mac HD:Users:facianp:Desktop:train:a-before:" as alias
(*tell application "Finder"
set this_file to every file of folder "Mac HD:Users:facianp:Desktop:train:a-before:"
end tell*)
--tell application "Finder" to set theFolder to "Mac HD:Users:facianp:Desktop:train:a-before:"
--on adding folder items to theFolder after receiving this_file
(*try
set theFolder to "Mac HD:Users:facianp:Desktop:train:a-before:" as alias
tell application "System Events" to set this_image to every file of theFolder
end try*)
Last edited by a moderator: