|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Apr 2002
Messaggi: 589
|
Individuare e Rimuovere cartelle vuote
Esiste qualche script o programma per individuare delle cartelle vuote ed eventualmente rimuoverle?
Tnx
__________________
ADDiCTED
|
|
|
|
|
|
#2 |
|
Member
Iscritto dal: Sep 2005
Messaggi: 82
|
una semplice possibilità consiste nell'usare AppleScript, ecco il risultato:
Codice:
on open parent_folder
my routine(parent_folder)
end open
on run
set parent_folder to ( choose folder with prompt “Select parent folder” default location ( path to home folder) without invisibles)
my routine(parent_folder)
end run
on routine(parent_folder)
display dialog “Are you sure you want to delete every empty folder inside:
“ & POSIX path of parent_folder buttons {“Exit”, “Continue”} default button 2 with icon caution
if result is “Exit” then
return
end if
set ret to my recurse(parent_folder, {”“, 0}, 1)
my show_log(ret, parent_folder)
end routine
on recurse(parent_folder, ret, root)
tell application “Finder”
repeat with child in (*get* folders of parent_folder)
set ret to my recurse(child, ret, 0)
end repeat
if root is 0 and (( count items) of parent_folder is 0 or ( count items) of parent_folder is 1 and name of item 1 of parent_folder is “.DS_Store”) then
set c to (*item* 2 of ret) + 1
set res to item 1 of ret & “
“ & c & “. “ & ( POSIX path of (parent_folder as string))
set ret to {res, c}
delete parent_folder
end if
end tell
return ret
end recurse
on show_log(ret, parent_folder)
display dialog “Do you want to see the log?” buttons {“Exit”, “Yes”} default button 2
if result is “Exit” then
return
end if
tell application “TextEdit”
activate
make new document
set text of document 1 to “” & (item 2 of ret) & “ folder(s) deleted in \”“ & ( POSIX path of parent_folder as string) & “\”:
“ & (*item* 1 of ret)
end tell
end show_log
Per sicurezza fai prima una prova con una cartella di test.
__________________
Saigon, shit. I'm still only in Saigon. |
|
|
|
|
|
#3 | |
|
Senior Member
Iscritto dal: Apr 2002
Messaggi: 589
|
Quote:
__________________
ADDiCTED
|
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 20:00.










ADDiCTED










