the 3400 picturerame applescript
here it is, in all its kludgy, fugly glory:
-- this script runs on startup and can be set to run periodically with something like the iDo Script Scheduler control panel
on run
tell application "Finder"
activate
set photoList to every file of the folder "all Pictures"
-- the "all pictures" folder is on the hard drive, sitting on the desktop
if exists folder "pictures" then
move folder "pictures" to the trash
-- the "pictures" folder is on the desktop, but is located on the RAM disk or PC flash memory card
try
empty the trash
end try
end if
end tell
renameFiles(photoList)
-- randomizes the pictures in the all pictures folder, since my preferred slideshow app doesn't do random display. and besides, you'll see below that i'm grabbing 25 at random to load onto a flash card, so the hard drive can spin down
tell application "Finder"
activate
-- make a new pictures folder, to contain the slideshow's images
make new folder at disk "16M PC Card"
select folder "untitled folder" of disk "16M PC Card"
set name of selection to "pictures"
move selection to desktop
-- grab the slideshow application, renamed " slideshow" so it always sorts first, and 25 images to load onto the flash card
select folder "all Pictures"
open selection
select items 1 through 26 of folder "all Pictures"
copy selection to folder "pictures"
close container window of folder "all Pictures"
-- run the slideshow application
select file " slideshow" of folder "pictures"
open selection
end tell
end run
to renameFiles(thePhotos)
set reNamePrefix to "image"
tell application "Finder"
repeat with i from 1 to count of thePhotos
set theName to name of item i of thePhotos
if theName contains ".jpg" then
set theRandom to random number 100000
set theRandom2 to random number 10000
set theRandom3 to random number 1000
try
set name of item i of thePhotos to ¬
reNamePrefix & theRandom & ".jpg"
on error
set name of item i of thePhotos to ¬
reNamePrefix & theRandom & theRandom2 & ".jpg"
-- oddly, a lot of duplication in the random numbers returned over time means errors. adding a second (and optionally a third) step to the process (almost) nullifies this. if i were smart, i'd have done this better, checking "If exists" before renaming, but i'm lazy
end try
end if
end repeat
end tell
end renameFiles
- option8's blog
- Log in or register to post comments