6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Flash Pro] 空フォルダを削除する君.jsfl

Last updated at Posted at 2012-02-17

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();

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?