I’m trying to create a script to run a function for me based on files I download from my site every day.
Basically, my site creates a folder based on the date (yyyy, mm, dd). I want applescript to first open that folder, and then run the action on each folder/file inside.
Trouble is, when I try to point my script to that folder using a variable, it gives me the error: Can’t make path name into a constant.
Maybe the REAL problem is how new I am to this! Here’s what I’ve tried:
tell application "Finder"
set {year:y, month:m, day:d} to (current date)
set theTime to y & m & d
set pathToTarget to path to theTime
open folder pathToTarget of folder "F-grams" of folder "files" of folder "default" of folder "sites" of folder "foldagram" of folder "htdocs" of folder "MAMP" of folder "Applications" of startup disk
end tell
Who wants to help a newbie get on track?
-JB
This folder action will be triggered every time a new item is added to the target folder. The second repeat block will allow you to send commands for each item within each added folder. You may reference each one of these items with the anItem variable. Save the script in the Folder Action Scripts folder in your Library. Be sure to attach the folder action to the target folder.
However, if you wanted to search for folders by date, this is how you should format the date string: