tell application id "DNtp" set monthNames to {"01_Januar", "02_Februar", "03_März", "04_April", "05_Mai", "06_Juni", "07_Juli", "08_August", "09_September", "10_Oktober", "11_November", "12_Dezember"} set monthVariants to {"januar", "jan", "january", ¬ "februar", "feb", "february", ¬ "märz", "maerz", "mrz", "mär", "march", "mar", ¬ "april", "apr", ¬ "mai", "may", ¬ "juni", "jun", "june", ¬ "juli", "jul", "july", ¬ "august", "aug", ¬ "september", "sep", "sept", ¬ "oktober", "okt", "october", "oct", ¬ "november", "nov", ¬ "dezember", "dez", "december", "dec"} set selRecs to selection as list if (count of selRecs) is 0 then display dialog "Bitte einen Ordner in DEVONthink auswählen." buttons {"OK"} default button "OK" return end if set targetGroup to first item of selRecs set targetName to name of targetGroup set normalizedTargetName to my normalizeMonthFolderName(targetName) if monthVariants contains normalizedTargetName then set answerButton to button returned of (display dialog "Du stehst im Ordner " & targetName & ". Willst du hier trotzdem einen Jahreszyklus anlegen?" buttons {"Abbrechen", "Ja"} default button "Ja" with icon caution) if answerButton is "Abbrechen" then return end if repeat with i from 1 to count of monthNames set monthName to item i of monthNames try create record with {name:monthName, type:group} in targetGroup end try end repeat try create record with {name:"Versendet", type:group} in targetGroup end try display dialog "Fertig." buttons {"OK"} default button "OK" end tell on normalizeMonthFolderName(theName) set t to (do shell script "printf %s " & quoted form of theName & " | tr '[:upper:]' '[:lower:]'") set t to my replaceText(".", "", t) set t to my replaceText("_", " ", t) set t to my replaceText("-", " ", t) set t to my trimText(t) try set t to do shell script "printf %s " & quoted form of t & " | sed -E 's/^[0-9]{1,3}[[:space:]]+//; s/^[0-9]{1,3}//'" on error -- falls sed zickt, einfach Original weiterverwenden end try set t to my trimText(t) return t end normalizeMonthFolderName on replaceText(findText, replaceWith, sourceText) set AppleScript's text item delimiters to findText set textItems to every text item of sourceText set AppleScript's text item delimiters to replaceWith set newText to textItems as text set AppleScript's text item delimiters to "" return newText end replaceText on trimText(t) set whitespaceChars to {space, tab, return, linefeed} repeat while t is not "" and (character 1 of t is in whitespaceChars) set t to text 2 thru -1 of t end repeat repeat while t is not "" and (character -1 of t is in whitespaceChars) set t to text 1 thru -2 of t end repeat return t end trimText