C-Command Software Forum

converting folders to tags

An AppleScript to append the containing folder for each selected record to the existing tag set – “container-to-tag”:

tell application “EagleFiler”
[INDENT]set _records to selected records of browser window 1
repeat with _record in _records
[INDENT]if _record’s container’s name is not “Files” then
[INDENT]set _record’s assigned tag names to (_record’s assigned tag names & _record’s container’s name)
end if[/INDENT]
end repeat[/INDENT]
end tell[/INDENT]

An elaborated version that appends the complete hierarchy of containing folders – “container-hierarchy-to-tags”:

tell application “EagleFiler”
[INDENT]set _records to selected records of browser window 1
repeat with _record in _records
[INDENT]get name of _record
set _container to container of _record
set _containerName to _container’s name
repeat until _containerName is “Files”
[INDENT]set _record’s assigned tag names to (_record’s assigned tag names & _containerName)
set _container to container of _container
set _containerName to _container’s name
end repeat[/INDENT]
end repeat[/INDENT]
end tell[/INDENT]

Suggested workflow:

  1. Run script.
  2. Move records to higher level (highest if running on all records).
  3. If all records from containing folders have been so moved, trash containing folder(s).

Usage notes:

  1. [NTIM] Folders are assigned tags.
  2. [IIMAD] Subfolders with identical names in different folders will be given identical tags.
  3. [FYI] Spaces in folder names are converted to underscores.