Comprimendo una cartella con il vostro PC Mac avrete notato che vengono inclusi anche dei file nascosti tipo
.svn .git .DS_Store Thumbs.db
Ecco come risolvere il problema in 2 minuti:
Aprite l'applicazione Automator
Alla richiesta del modello da creare selezionate Servizio e confermate con il tasto Scegli
In alto come ricezioni impostate "Documenti e Cartelle" in "Finder"
Dall'elenco sulla sinistra selezionate dalla categoria "Utility" l'azione "Esegui Apple Script" e trascinatela nell'area di destra
Troverete gia' scritto del codice di esempio :
on run {input, parameters}
(* Your script goes here *)
return input
end run
Cancellate tutto e incollate il codice seguente:
on run {input, parameters}
tell application "Finder"
set n to count of input
set oggetto to (first item of input as string)
set Dir to ((container of item oggetto) as string)
set cartella to quoted form of POSIX path of Dir
set nome to ""
repeat with i in input
set nome to (quoted form of ((name of i) as string) & " " & nome)
end repeat
if n = 1 then
set nome_se to my nome_senza_estensione(oggetto)
else
set nome_se to "Archivio"
end if
if item (Dir & nome_se & ".zip") exists then
set theDate to current date
set theYear to year of theDate as text
set theMonth to (month of theDate as integer) as text
if length of theMonth < 2 then
set theMonth to ("0" & theMonth)
end if
set theDay to (day of theDate) as text
if length of theDay < 2 then
set theDay to ("0" & theDay)
end if
set theTime to (characters 1 thru 2 of time string of theDate) & (characters 4 thru 5 of time string of theDate) & (characters 7 thru 8 of time string of theDate)
set nome_se to (nome_se & "_" & theYear & theMonth & theDay & "-" & theTime)
end if
do shell script "cd " & cartella & "; zip -r --exclude=*.DS_Store* --exclude=*.svn* --exclude=*.git* --exclude=*Thumbs.db* " & quoted form of nome_se & " " & nome
end tell
return input
end run
on nome_senza_estensione(an_item)
tell application "Finder"
set theName to (name of item an_item) as text
set theExtension to (name extension of item an_item) as text
if theExtension is not "" then
set x to the offset of theExtension in theName
set theName to text 1 thru (x - 2) of theName
end if
return theName
end tell
end nome_senza_estensione
Ora salvare il tutto ed assegnare un nome appropriato al Servizio, es: "Crea Zip Pulito"
A questo punto "cliccando col tasto destro" su una cartella oppure su un insieme di file troverete la funzione "Crea Zip Pulito" che genererà un archivio di tipo .zip senza i classici file nascosti generati da OS-X
