Skip to content

Instantly share code, notes, and snippets.

@joebuhlig
Created October 12, 2015 18:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joebuhlig/8226fc344b6bf5da6945 to your computer and use it in GitHub Desktop.
Save joebuhlig/8226fc344b6bf5da6945 to your computer and use it in GitHub Desktop.
set thePList to "Users:JoeBuhlig:Dropbox:pList:Project_Codes.plist"
set thePListPath to POSIX path of thePList
tell application "System Events"
tell property list file thePListPath
tell contents
set pcode to value of property list item "HouseCar"
set yr to text -2 thru -1 of ("00" & (year of (current date))) as number
set y to text -6 thru -5 of pcode as number
set inc to text -2 thru -1 of pcode as number
if (yr > y) then
set inc to 1
else
set inc to inc + 1
end if
set inc to text -2 thru -1 of ("00" & inc)
set newcode to yr & "HC" & inc as string
set value of property list item "HouseCar" to newcode
end tell
end tell
end tell
return newcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment