Quantcast
Channel: Planet DTP@jp
Viewing all articles
Browse latest Browse all 4835

FORCE: 不可視ファイルを削除する

$
0
0


ローカルディスク上のフォルダを選択した場合

findコマンドを使って削除する

リムーバブルディスクの場合

dot_cleanコマンドを使って削除します。


ftpを使ってマルっとアップロードする時用

--dot_clean.scpt
(*
不可視ファイルを削除する
選択したディレクトリが『リムーバブル』なら
dot_cleanでクリーニングする
選択したディレクトリがローカルの場合は
findを使って削除する
*)

onrun
---プロンプトの文言改行が使えます\nを入れます
settheWithPromptto".』ドットからはじまるリソースファイルを削除します"
---ファイル選択ダイアログのデフォルトのディレクトリ
settheDefLoctoPOSIX file"/Volumes"
---ダイアログを出して選択されたファイルは「open」に渡す
open (choose folderdefault locationtheDefLoc¬
with prompttheWithPrompt¬
invisiblestrue¬
withmultiple selections allowedwithoutshowing package contents)
endrun



onopenobjOpenPath
---リストから読み込む順番の初期化
setnumCntListto 1 asnumber
---繰り返し回数の初期化
setnumCntRepeatto 0 asnumber
---リストの項目数を数える
setnumCntRepeatto (countofobjOpenPath) asnumber
---リピートの開始
repeatnumCntRepeattimes
---順番に読み込む
settheReadTextFileLineto (itemnumCntListofobjOpenPath) astext
---openからの返り値をUNIXパスに変換
settheOpenPathtoPOSIX pathoftheReadTextFileLineastext
---区切り文字を指定して
setAppleScript's text item delimitersto":"
---パスをリストに格納します
setlistObjPathtotext itemsoftheReadTextFileLine
---区切り文字は戻しておきます
setAppleScript's text item delimitersto""
---パスの最初の文字=ディスクの名前を取得しておきます
settheObjPathDiskNameto (item 1 oflistObjPath) astext
---そのディスクが取り外し可能か?ローカルか?を判定
tellapplication"Finder"
settheEjectableDiskNameto (getnameofdiskswhoselocal volume = trueandejectable = true) astext
endtell
---ローカルディスク|リームーバブルならdot_cleanを使う
iftheEjectableDiskNamecontainstheObjPathDiskNamethen
---コマンドをテキストで整形
settheCmdComto ("dot_clean -m \"" & theOpenPath& "\"") astext
---コマンドを実行
try
do shell scripttheCmdCom
endtry
log"Done dot_clean"
else
---ネットワークボリュームや排出出来ない(起動ディスク)ボリュームの場合はFindを使う
---TemporaryItemsフォルダを削除
settheCmdComto ("find \"" & theOpenPath& "\" -name \".TemporaryItems\" -depth -exec rm -Rf {} \\;") astext
try
do shell scripttheCmdCom
endtry
---DS_Store削除
settheCmdComto ("find \"" & theOpenPath& "\" -name \".DS_Store\" -depth -exec rm {} \\;") astext
try
do shell scripttheCmdCom
endtry
---localized削除
settheCmdComto ("find \"" & theOpenPath& "\" -name \".localized\" -depth -exec rm {} \\;") astext
try
do shell scripttheCmdCom
endtry
---Thumbs.db削除
settheCmdComto ("find \"" & theOpenPath& "\" -name \"Thumbs.db\" -depth -exec rm {} \\;") astext
try
do shell scripttheCmdCom
endtry
---Desktop.ini削除
settheCmdComto ("find \"" & theOpenPath& "\" -name \"Desktop.ini\" -depth -exec rm {} \\;") astext
try
do shell scripttheCmdCom
endtry
---Bridgeのキャッシュ削除
settheCmdComto ("find \"" & theOpenPath& "\" -name \".BridgeSort\" -depth -exec rm {} \\;") astext
try
do shell scripttheCmdCom
endtry
---Bridgeのキャッシュ削除
settheCmdComto ("find \"" & theOpenPath& "\" -name \".BridgeLabelsAndRatings\" -depth -exec rm {} \\;") astext
try
do shell scripttheCmdCom
endtry
---分割されたリソースフォークファイルを削除
settheCmdComto ("find \"" & theOpenPath& "\" -name \"._*\" -depth -exec rm {} \\;") astext
try
do shell scripttheCmdCom
endtry
log"Done Find"
endif
---読み込み順をカウントアップ
setnumCntListtonumCntList + 1 asnumber
endrepeat
endopen


「dot_clean.scpt.zip」をダウンロード


Viewing all articles
Browse latest Browse all 4835

Trending Articles