Ho un AppleScript che è stato scritto e funziona come tale, ma ho bisogno di cambiare il modo in cui crea la struttura delle cartelle. Lo script fa quanto segue:
- La cartella è selezionata che contiene i file (nel mio caso saranno le foto).
- Verrà quindi visualizzata la data di creazione delle immagini.
- Crea una YYYY (cartella Anno se non già creata).
- Crea un MM (cartella Mese se non già creata).
- Crea un DD (cartella Day se non già creata).
- Sposta quindi la foto in questa cartella e la ripete per la foto successiva e la ripete fino al completamento.
La struttura attuale della cartella viene creata come segue:
2018 "YYYY"
├── 2018-01 "MM"
├── 2018-02
Questo è fantastico e funziona come progettato, ma ho cambiato idea su come vorrei che fossero le cartelle. Vorrei la seguente struttura (che è quasi la stessa solo una diversa struttura di denominazione:
2018
├── 001 January
│   ├── 20180101
│   └── 20180102
├── 002 February
│   ├── 20180201
│   └── 20180202
└── 003 March
    ├── 20180301
    └── 20180302
Ora ho cercato di capire dove lo script genera questo, ma ho fallito, quindi ora mi sto rivolgendo a questo ottimo posto per un po 'di aiuto.
on run
    SortFiles(POSIX path of (choose folder))
end run
on open (DroppedFolder)
    set DroppedFolder to POSIX path of DroppedFolder
    if text (length of text of DroppedFolder) of DroppedFolder is not "/" then quit
    SortFiles(DroppedFolder)
end open
on SortFiles(SortFolder)
    set AppleScript's text item delimiters to return
    set SortFolderContents to the text items of (do shell script "find '" & SortFolder & "' -type f")
    set FolderMakeList to {}
    repeat with ThisItem in SortFolderContents
        set ThisFile to ThisItem as string
        if ThisFile does not contain "/." then
            tell application "Finder"
                set DateString to text 1 thru 7 of ((creation date of ((POSIX file ThisFile) as alias)) as «class isot» as string)
                set ThisFilesFolder to SortFolder & text 1 thru 4 of DateString & "/"
                set ThisFilesSubfolder to ThisFilesFolder & text 1 thru 7 of DateString & "/"
            end tell
            if ThisFilesFolder is not in FolderMakeList then
                try
                    do shell script ("mkdir '" & ThisFilesFolder & "'")
                end try
                set FolderMakeList to FolderMakeList & ThisFilesFolder
            end if
            if ThisFilesSubfolder is not in FolderMakeList then
                try
                    do shell script ("mkdir '" & ThisFilesSubfolder & "'")
                end try
                set FolderMakeList to FolderMakeList & ThisFilesSubfolder
            end if
            try
                do shell script ("mv '" & ThisFile & "' '" & ThisFilesSubfolder & "'")
            end try
        end if
    end repeat
    return FolderMakeList
end SortFiles