I handle the digital signage for a university and I currently have an older Mac Pro set up to show a screen saver drawing from a folder of images I sync with DropBox. These images show upcoming events, student notices, a welcome splash screen etc.
I am trying to write a script (or scripts) that will do two things daily:
1) Check a "Slides to Rotate In" folder for a start date in each filename, and if the date found is past the current date, it would move the file to the "Current Slides" folder. After moving all necessary files, it would stop and restart the slideshow.
2) Check the "Current Slides" folder for an end date in each filename, and if the end date is past the current date, it would move the file to the "Old Slides" folder. Same deal with the screen saver afterwards.
The files are named as such "002-CH10-20141013-20141023-common hour oct 20.jpg", where 002-CH10 is a category and identifier, 20141013 is the date that slide should start running, 20141023 is the date that the slide should be removed from rotation, and the trailing section is just a descriptor for my own sake.
Here is the code I have so far for number 1 up above (number 2 would be pretty much the same), kind of cobbled together from some other info I found online before coming here:
EDIT: I commented out the various "return" commands and got it to progress through to the point where it tells the Finder to move the file to the new folder. I think that's my only stumbling point right now. Any thoughts?
I am trying to write a script (or scripts) that will do two things daily:
1) Check a "Slides to Rotate In" folder for a start date in each filename, and if the date found is past the current date, it would move the file to the "Current Slides" folder. After moving all necessary files, it would stop and restart the slideshow.
2) Check the "Current Slides" folder for an end date in each filename, and if the end date is past the current date, it would move the file to the "Old Slides" folder. Same deal with the screen saver afterwards.
The files are named as such "002-CH10-20141013-20141023-common hour oct 20.jpg", where 002-CH10 is a category and identifier, 20141013 is the date that slide should start running, 20141023 is the date that the slide should be removed from rotation, and the trailing section is just a descriptor for my own sake.
Here is the code I have so far for number 1 up above (number 2 would be pretty much the same), kind of cobbled together from some other info I found online before coming here:
Code:
to extractStartDate(filename)
set TempID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "-"
set fnParse to every text item of filename
set returnStartDate to text item 3 of fnParse
set AppleScript's text item delimiters to TempID
end extractStartDate
to date_format(old_date)
set {year:y, month:m, day:d} to result
set todayDate to (y * 10000 + m * 100 + d)
end date_format
set old_date to current date
set todayDate to date_format(old_date)
-- return todayDate
set filez to "/Users/<username>/Dropbox/Music School/Lobby Slides/Slides to Rotate In/"
set dropBox to "/Users/<username>/Dropbox/Music School/Lobby Slides/Current Slides/"
tell application "System Events" to set theFolderList to the name of every file of folder filez whose visible is true
repeat with fa from 1 to count of theFolderList
set fn to text item fa of theFolderList
-- return fn
set addDate to extractStartDate(fn)
-- return addDate
if addDate comes before todayDate then
tell application "Finder" to move fn to folder dropBox
end if
end repeat
tell application "System Events"
stop current screen saver
start current screen saver
end tell
EDIT: I commented out the various "return" commands and got it to progress through to the point where it tells the Finder to move the file to the new folder. I think that's my only stumbling point right now. Any thoughts?
Last edited: