Sunday, 2 October 2011

Watching GIFs on OSX

One thing I really love are GIFs but OSX and iPhoto don’t play them natively so I build the following Applescript to generate a local web page which lists and displays all my GIFs that are located in a specific folder.


You can download the .scpt here.



set gifFolderName to "gif:"
set gifDisplayPage to "GIFDisplayPage.html"

tell application "Finder"
set currentFolder to container of (path to me) as string
set gifFolderPath to (currentFolder & gifFolderName)
set fileList to every file of folder gifFolderPath
-- display dialog currentFolder
end tell

set gifPage to (currentFolder & gifDisplayPage)
set htmlStart to "Watch your GIFs" as string
set htmlEnd to "" as string

try
open for access file gifPage with write permission
write htmlStart to file gifPage as string
repeat with currentFile in fileList
set currentFileName to (name of currentFile)
write ("<img src="gif/&quot; &amp; currentFileName &amp; &quot;" alt="" />") to file gifPage as string
end repeat
write htmlEnd to file gifPage as string
close access file gifPage
on error errorMessage
log errorMessage
try
close access file gifPage
end try
end try

tell application "Finder"
open file gifPage
end tell

0 comments: