Flash Proの[ライブラリ]パネルで、要素が0個のフォルダを削除してするJSFLです。
function cleanLibraryFolder(){
var lib = fl.getDocumentDOM().library;
var folders = {};
for(var i=0; i<lib.items.length; i++){
var o = lib.items[i];
var n = o.name;
var obj = getItemObject(o.name);
if(o.itemType == "folder"){
folders[o.name] = 0;
}
folders[obj.folder]++;
}
var cnt = 0;
fl.trace("");
fl.trace("----- Clean Library Folder -----");
for(var p in folders){
if(folders[p] == 0){
cnt++;
lib.deleteItem(p);
fl.trace("Delete: '" + p + "'");
}
}
fl.trace("");
fl.trace(cnt + " folder is deleted.");
fl.trace("");
}
function getItemObject(path){
var arr = path.split("/");
var n = arr.pop();
return {
folder: arr.join("/"),
name: n
}
}
cleanLibraryFolder();