-- Ordner wählen, alle Dateien unterhalb dieses Ordner werden mit den Namen ihrer überordner getagged, und mit dem Namen der Datei selber
-- BSP: Datei in Projekte/Client XY/Bilder/bahnhof - wird mit Projekte, Client XY, Bilder, Bahnhof getagged
set Ordner to (choose folder)
global startOrdner
set startOrdner to the length of (POSIX path of Ordner)
property type_list : {"TIFF", "JPEG", "PNGf", "PICT"}
BearbeiteOrdner(Ordner)
-- Alle Ordner holen
on BearbeiteOrdner(inOrdner)
tell application "Finder"
-- hier kann man noch einen Datei Filter einbauen
set theFileList to (every file of inOrdner) --whose file type is in the type_list or name extension is in the extension_list
set OrdnerListe to every folder of inOrdner
repeat with i from 1 to length of OrdnerListe
my BearbeiteOrdner(item i of OrdnerListe)
end repeat
end tell
repeat with theFile in theFileList
set this_info to info for theFile as alias
if visible of this_info is true and alias of this_info is false then
set this_name to name of this_info
set extension_length to length of name extension of this_info
set this_path to POSIX path of (theFile as string)
set temp to substr(this_path, startOrdner + 1, (length of this_path))
set temp to substr(temp, 1, -extension_length - 2)
set tempArray to my theSplit(temp, "/")
set tags to ""
repeat with tempValue in tempArray
set tags to tags & " " & quoted form of tempValue
end repeat
-- pfad zum commandline programm openmeta
-- http://code.google.com/p/openmeta/
do shell script "/Users/yene/Downloads/1.2.0/openmeta -a " & tags & " -p " & quoted form of this_path
--display dialog tags
end if
end repeat
end BearbeiteOrdner
on theSplit(theString, theDelimiter)
-- save delimiters to restore old settings
set oldDelimiters to AppleScript's text item delimiters
-- set delimiters to delimiter to be used
set AppleScript's text item delimiters to theDelimiter
-- create the array
set theArray to every text item of theString
-- restore the old setting
set AppleScript's text item delimiters to oldDelimiters
-- return the result
return theArray
end theSplit
-- string substr ( string $string , int $start [, int $length ] )
on substr(theString, theStart, theLength)
set myList to every character of theString
set myList to items theStart through theLength of myList
return myList as string
end substr