OS X - AppleScript domanda sullo spostamento dei file ogni giorno in un'altra cartella (cartelle variano)

apple.stackexchange https://apple.stackexchange.com/questions/2892

Domanda

Attualmente sto usando questo ( http: / /lifehacker.com/193778/download-of-the-day--auto+applescript-tickler-file ) per un file tickler del sistema e lo hanno messa a punto nel mio Dropbox (in modo che funziona su tutti i sistemi). Ci sono solo un paio di cose da fare perfetto. Se qualcuno mi può aiutare che sarebbe eccellente.

Quello che sto cercando è uno script o di flusso di lavoro che avrà il contenuto delle cartelle per il giorno precedente (cambiano ogni giorno e sono numerati) e passare al giorno corrente. Allora posso impostarlo come un allarme per eseguire al mattino ogni giorno.

Grazie mille.

È stato utile?

Soluzione

Se ho capito bene le vostre esigenze, allora questo script dovrebbe fare quello che vuoi. Assicurarsi di cambiare il nome utente sulla prima riga al vostro nome utente.

set username to "lizzan"

set cy to (year of (current date)) as integer
set cm to (month of (current date)) as integer
set cd to (day of (current date)) as integer

set yd to yesterday(cy, cm, cd)

set yy to item 1 of yd
set ym to item 2 of yd
set yd to item 3 of yd


set yFolder to "Macintosh HD:Users:" & username & ":Documents:To Do:" & yy & ":" & ym & ":" & yd
set cFolder to "Macintosh HD:Users:" & username & ":Documents:To Do:" & cy & ":" & cm & ":" & cd

tell application "Finder"
    move every file of folder yFolder to cFolder
end tell

on yesterday(y, m, d)
    set d to d - 1

    if d ≤ 0 then
        set m to m - 1
        if m ≤ 0 then
            set y to y - 1
            set m to 12
        end if
        set thirtyones to {1, 3, 5, 7, 8, 10, 12}
        set thirties to {4, 6, 9, 11}
        if m is in thirtyones then
            set d to 31
        else if m is in thirties then
            set d to 30
        else if leapyear(y) then
            set d to 29
        else
            set d to 28
        end if

    end if

    set yd to {y, m, d}
    return yd

end yesterday

on leapyear(y)
    if y mod 4 is 0 then
        if y mod 100 is 0 then
            if y mod 400 is 0 then
                return true
            end if
            return false
        end if
        return true
    end if

    return false

end leapyear

Caveat: lo script avrà esito negativo (e si sono trasferiti, eventualmente, solo alcuni dei file) se è già presente un file con lo stesso nome nella cartella si sta muovendo a. Se si desidera sostituire i file in questo caso, ed evitare in mancanza, aggiungere with replacing alla fine della linea 18 (move every ... to cFolder with replacing).

Modifica per aggiungere: Oh, appena visto che si aveva da esso istituito nel vostro Dropbox invece che nella cartella Documenti. Basta cambiare i percorsi sulle linee 14 e 15 in modo da riflettere il percorso che si sta utilizzando, e dovrebbe andare bene.

Altri suggerimenti

Una soluzione molto semplice è un Automator applicazione (flusso di lavoro che viene eseguito in modo indipendente). Sono voluti circa 15 secondi (letteralmente) per impostare questo flusso di lavoro su: alt text

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a apple.stackexchange
scroll top