Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tell application "Finder"
- set theSelected to (get the selection) as list
- set theOutputFolder to choose folder with prompt "Please select an output folder:" --choose a save location for the DB
- repeat with b from 1 to the count of theSelected
- set fls to every folder in (item b of theSelected) as list --turn subfolders into variable
- if (count of fls) is less than 1 then
- set theSFolder to (item b of theSelected)
- set fls to theSelected
- else
- set theSFolder to item 1 of fls --set subfolder to begin with
- end if
- tell application "Database Events"
- set theDatabase to make new database with properties {name:"ArtFolders", location:theOutputFolder} --creata new DB
- tell theDatabase --choose DB to change
- repeat with a from 1 to count of fls --repeats for every subfolder found
- set theSFolder to item a of fls --chooses a subfolder for the repeat command
- set theFolderName to name of theSFolder as Unicode text --get subfolder name
- set theFolderLoc to {POSIX path of (theSFolder as Unicode text)} --get subfolder path
- set theRecord to make new record with properties {name:theFolderName} --make new DB entry
- tell theRecord --choose DB record to change
- make new field with properties {name:"Location", value:(theFolderLoc as Unicode text)} --assign new field
- end tell
- if a is not 1 then --last item from repeat list?
- set theSFolder to item (a - 1) of fls --if not, move to the next
- end if
- end repeat
- end tell
- end tell
- if b is not 1 then --last item from repeat list?
- set b to {b - 1} --if not, move to the next
- end if
- end repeat
- tell application "Database Events"
- close database "ArtFolders" saving yes --close/save DB
- end tell
- end tell
- activate
- display alert "ArtFolders database has been updated" buttons {"Cool Story"}
Advertisement
Add Comment
Please, Sign In to add comment