-- Benutzer wählt einen Ordner aus set theFolder to choose folder with prompt "Wähle den Ordner mit den umzubenennenden Dateien:" tell application "Finder" set fileList to every file of theFolder repeat with aFile in fileList set oldName to name of aFile -- Versuche ein Datum im Format dd.mm.yyyy zu erkennen try set AppleScript's text item delimiters to "." set nameParts to text items of oldName if (count of nameParts) ≥ 3 then set dayPart to item -3 of nameParts set monthPart to item -2 of nameParts set yearPart to item -1 of nameParts -- Jahr extrahieren (ggf. inklusive Dateiendung wie "2024.pdf") set AppleScript's text item delimiters to "." set yearItems to text items of yearPart set trueYear to item 1 of yearItems -- Neuen Namen zusammensetzen (ersetze nur das Datumsteil) set newDate to trueYear & "." & monthPart & "." & dayPart -- Altes Datum im Dateinamen finden set oldDate to dayPart & "." & monthPart & "." & trueYear -- Neuen Namen erzeugen set newName to my replaceText(oldDate, newDate, oldName) -- Umbenennen set name of aFile to newName end if end try end repeat end tell -- Hilfsfunktion zum Ersetzen von Text on replaceText(findText, replaceText, theString) set AppleScript's text item delimiters to findText set theItems to text items of theString set AppleScript's text item delimiters to replaceText return theItems as string end replaceText