daily pastebin goal
36%
SHARE
TWEET

Jason Snell's Template Gun

a guest Sep 7th, 2018 169 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use AppleScript version "2.4" -- Yosemite (10.10) or later
  2. use scripting additions
  3.  
  4. set nameArray to {}
  5.  
  6. set templateFolder to (alias "Macintosh HD:Users:jsnell:Dropbox:Podcast Templates:")
  7.  
  8. tell application "Finder"
  9.     set theItems to the items in folder templateFolder
  10.     set theNames to the name of items in folder templateFolder
  11. end tell
  12.  
  13. set mychoice to (choose from list theNames with prompt "Choose your Template" default items "None" OK button name {"Choose"} cancel button name {"Cancel"}) as string
  14.  
  15.  
  16. tell application "Finder"
  17.     duplicate item ((templateFolder as text) & mychoice) as alias to (path to desktop folder)
  18.     open item ((path to desktop folder as string) & mychoice) as alias
  19.     delay 2
  20.     delete item ((path to desktop folder as string) & mychoice) as alias
  21. end tell
  22.  
  23.  
  24.  
  25.  
  26. if mychoice contains "Download" then
  27.    
  28.     set unixDate to (do shell script "date +'%s'") as number
  29.     set premiere to "1493316000" as number
  30.     set newdate to unixDate - premiere -- seconds since premiere
  31.     set newdate to newdate / 86400 -- days since premiere
  32.     set weekcount to newdate / 7 --weeks since premiere
  33.     set weekcount to weekcount as integer
  34.     set weekcount to (weekcount - 1) --adjust for extra episodes
  35.     set theNewName to ("Download " & (weekcount as string))
  36.     tell application "System Events"
  37.         set name of file (((path to desktop folder) as string) & "Download Template:download.logicx") to (("download" & weekcount as string) & ".logicx")
  38.         set name of folder (((path to desktop folder) as string) & "Download Template") to theNewName
  39.     end tell
  40. end if
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top