PS: probier mal das…
der Quellordner ist ~/Scans
der Zielordner ist ~/Documents/Ablage
Die Monatsordner werden automatisch erstellt, falls nicht vorhanden
der Zielordner ist ~/Documents/Ablage
Die Monatsordner werden automatisch erstellt, falls nicht vorhanden
Show Plain Text
- set scanFolder to (path to home folder as text) & "Scans:"
- set ablageFolder to (path to documents folder as text) & "Ablage:"
- tell application "Finder" to set theFiles to sort (get files of folder scanFolder) by creation date
- repeat with aFile in theFiles
- tell application "Finder"
- set creationDate to creation date of aFile
- set fileExtension to name extension of aFile
- tell creationDate to set {yr, mt, dy, tm} to {its year, its month as integer, its day, its time string}
- end tell
- set monthString to pad(mt)
- set dateString to (yr as text) & monthString & pad(dy) & (words of tm as text)
- set sourceFile to quoted form of POSIX path of (aFile as text)
- set destinationFolder to quoted form of (POSIX path of ablageFolder & monthString)
- do shell script "/bin/mkdir -p " & destinationFolder
- set destinationFile to quoted form of (POSIX path of ablageFolder & monthString & "/" & dateString & "." & fileExtension)
- do shell script "mv " & sourceFile & space & destinationFile
- end repeat
- on pad(v)
- return text -2 thru -1 of ((v + 100) as text)
- end pad