Guest User

Untitled

a guest
Jul 30th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. tell application "Finder"
  2. set theSelected to (get the selection) as list
  3. set theOutputFolder to choose folder with prompt "Please select an output folder:" --choose a save location for the DB
  4. repeat with b from 1 to the count of theSelected
  5.  
  6. set fls to every folder in (item b of theSelected) as list --turn subfolders into variable
  7. if (count of fls) is less than 1 then
  8. set theSFolder to (item b of theSelected)
  9. set fls to theSelected
  10. else
  11. set theSFolder to item 1 of fls --set subfolder to begin with
  12. end if
  13.  
  14. tell application "Database Events"
  15. set theDatabase to make new database with properties {name:"ArtFolders", location:theOutputFolder} --creata new DB
  16. tell theDatabase --choose DB to change
  17. repeat with a from 1 to count of fls --repeats for every subfolder found
  18. set theSFolder to item a of fls --chooses a subfolder for the repeat command
  19. set theFolderName to name of theSFolder as Unicode text --get subfolder name
  20. set theFolderLoc to {POSIX path of (theSFolder as Unicode text)} --get subfolder path
  21. set theRecord to make new record with properties {name:theFolderName} --make new DB entry
  22. tell theRecord --choose DB record to change
  23. make new field with properties {name:"Location", value:(theFolderLoc as Unicode text)} --assign new field
  24. end tell
  25. if a is not 1 then --last item from repeat list?
  26. set theSFolder to item (a - 1) of fls --if not, move to the next
  27. end if
  28. end repeat
  29. end tell
  30. end tell
  31. if b is not 1 then --last item from repeat list?
  32. set b to {b - 1} --if not, move to the next
  33. end if
  34. end repeat
  35.  
  36. tell application "Database Events"
  37. close database "ArtFolders" saving yes --close/save DB
  38. end tell
  39. end tell
  40. activate
  41. display alert "ArtFolders database has been updated" buttons {"Cool Story"}
Advertisement
Add Comment
Please, Sign In to add comment