var lib = fl.getDocumentDOM().library; //Temporary Array of Items to Move because library structure will change var tempItems = lib.items; //Run over all objects in the tempItems Array for(var i in tempItems){ //fl.outputPanel.trace(tempItems[i].name + " : " + tempItems[i].itemType); if(tempItems[i].itemType == "bitmap"){ organizeBitmap(tempItems[i]); } else if(tempItems[i].itemType == "component"){ organizeComponent(tempItems[i]); } else if(tempItems[i].itemType == "compiled clip"){ organizeCompiledClip(tempItems[i]); } else if(tempItems[i].itemType == "movie clip"){ organizeMovieClip(tempItems[i]); } else if(tempItems[i].itemType == "graphic"){ organizeGraphic(tempItems[i]); } else if(tempItems[i].itemType == "button"){ organizeButton(tempItems[i]); } else if(tempItems[i].itemType == "video"){ organizeVideo(tempItems[i]); } else if(tempItems[i].itemType == "font"){ organizeFont(tempItems[i]); } else if(tempItems[i].itemType == "sound"){ organizeSound(tempItems[i]); } else if(tempItems[i].itemType == "folder"){ //do nothing } } function organizeSound(i){ if(!lib.itemExists("Sounds")){ lib.newFolder("Sounds"); } lib.moveToFolder("Sounds", i.name); } function organizeFont(i){ if(!lib.itemExists("Fonts")){ lib.newFolder("Fonts"); } lib.moveToFolder("Fonts", i.name); } function organizeVideo(i){ if(!lib.itemExists("Video")){ lib.newFolder("Video"); } lib.moveToFolder("Video", i.name); } function organizeButton(i){ if(!lib.itemExists("Buttons")){ lib.newFolder("Buttons"); } lib.moveToFolder("Buttons", i.name); } function organizeGraphic(i){ if(!lib.itemExists("Graphics")){ lib.newFolder("Graphics"); } lib.moveToFolder("Graphics", i.name); } function organizeMovieClip(i){ if(!lib.itemExists("MovieClips")){ lib.newFolder("MovieClips"); } lib.moveToFolder("MovieClips", i.name); } function organizeCompiledClip(i){ if(!lib.itemExists("CompiledClips")){ lib.newFolder("CompiledClips"); } lib.moveToFolder("CompiledClips", i.name); } function organizeComponent(i){ if(!lib.itemExists("Components")){ lib.newFolder("Components"); } lib.moveToFolder("Components", i.name); } function organizeBitmap(i){ if(i.name.toLowerCase().indexOf(".jpg") != -1 || i.name.toLowerCase().indexOf(".jpeg") != -1){ if(!lib.itemExists("Bitmaps/JPGs")){ lib.newFolder("Bitmaps/JPGs"); } lib.moveToFolder("Bitmaps/JPGs", i.name); } else if(i.name.toLowerCase().indexOf(".png") != -1){ if(!lib.itemExists("Bitmaps/PNGs")){ lib.newFolder("Bitmaps/PNGs"); } lib.moveToFolder("Bitmaps/PNGs", i.name); } else if(i.name.toLowerCase().indexOf(".gif") != -1){ if(!lib.itemExists("Bitmaps/GIFs")){ lib.newFolder("Bitmaps/GIFs"); } lib.moveToFolder("Bitmaps/GIFs", i.name); } else { if(!lib.itemExists("Bitmaps")){ lib.newFolder("Bitmaps"); } lib.moveToFolder("Bitmaps", i.name); } }