-- Name for the ScreenShots Folder on the desktop property ScreenShots : "Screen Shots" -- set the "FileFormat" to be used -- tested with "pdf", "png", "jpg" and "tif". property FileFormat : "png" on adding folder items to this_folder after receiving these_items repeat with an_item in these_items set file_name to name_file(an_item) if file_name starts with "Picture" and file_name ends with ".pdf" then -- Create a Screen Shots folder if one does not exist try do shell script "mkdir \"$HOME/Desktop/" & ScreenShots & "\"" end try -- The next step gurantees that the snapshot -- is not empty before moving it. set my_size to file_size(an_item) repeat until file_size(an_item) > 0 and file_size(an_item) = my_size delay 0.5 set my_size to file_size(an_item) end repeat set picture_name to my getSafeName(when(an_item)) set randomNumber to (random number) as string set temp_name to "temp" & randomNumber & ".pdf" (* The folllowing does the same as this but faster! tell application "Finder" set the name of document file an_item to temp_name move document file temp_name of desktop to the folder ScreenShots of the desktop end tell *) do shell script "mv \"$HOME/Desktop/" & file_name & "\" \"$HOME/Desktop/" & ScreenShots & "/" & temp_name & "\"" tell me to convertPicture(an_item, picture_name) beep end if end repeat end adding folder items to on getSafeName(file_name) set ScreenShots_path to (path to desktop as Unicode text) & ScreenShots & ":" try alias (ScreenShots_path & file_name & "." & FileFormat) set i to 1 repeat set i to i + 1 set path_to_check to (ScreenShots_path & file_name & " " & i & "." & FileFormat) try alias path_to_check on error set picture_name to file_name & " " & i & "." & FileFormat exit repeat end try end repeat on error set picture_name to (file_name & "." & FileFormat) end try return picture_name end getSafeName on convertPicture(pdf_file, picture_name) if the FileFormat is "pdf" then (* tell application "Finder" set the name of the pdf_file to picture_name end tell *) set pdf_path to quoted form of the POSIX path of pdf_file set save_path to quoted form of ((POSIX path of (path to desktop)) & ScreenShots & "/" & picture_name) do shell script "mv " & pdf_path & " " & save_path else if FileFormat is "jpg" then set FileFormat to "jpeg" else if FileFormat is "tif" then set FileFormat to "tiff" end if set pdf_name to name_file(pdf_file) set save_path to quoted form of ((POSIX path of (path to desktop)) & ScreenShots & "/") do shell script "cd " & save_path & "; sips -i -s format " & FileFormat & " " & pdf_name & " --out \"" & picture_name & "\"; rm " & pdf_name end if end convertPicture -- procedure to get a file's size in kilobytes on file_size(my_file) try get word 1 of (do shell script "du -k " & quoted form of the POSIX path of my_file) as integer return the result on error return 0 end try end file_size -- procedure to get a file's name from its path on name_file(an_item) -- Save the default Applescript delimiter set savedTextItemDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to {":"} -- get the file_name from its path set file_name to the last text item of (an_item as string) -- Restore the default Applescript delimiter set AppleScript's text item delimiters to savedTextItemDelimiters return file_name end name_file -- procedure to get a string with a file's creation date on when(my_file) set my_file_path to the POSIX path of my_file do shell script "bin/ls -lT " & quoted form of my_file_path set the creation_time to the result set num_words to ((count words of creation_time) as integer) - (count words of my_file_path) as integer set creation_time to words (num_words - 5) through num_words of creation_time set my_date to item 1 of creation_time & " " & item 2 of creation_time & " " set my_hour to item 3 of creation_time if my_hour as integer > 12 then set my_hour to ((my_hour as integer) - 12) as string set AMPM to "PM" else if my_hour as integer = 0 then set my_hour to "12" set AMPM to "AM" else set AMPM to "AM" end if set my_hour to my_hour & "." set my_minutes to item 4 of creation_time & "." set my_seconds to item 5 of creation_time set my_year to item 6 of creation_time & " " set creation_time to my_date & my_year & my_hour & my_minutes & my_seconds & AMPM return creation_time end when