Copy link to clipboard
Copied
Hi I am trying to modify this script to export selected Movie Clips from library to PNGs and keep original name of the MC. I have the script that works well exporting selected bitamps from library, but I am trying yo modify it to export also Movie clips.
function exportLibraryImagesToFiles() {
var doc = fl.getDocumentDOM();
if (!doc) return;
var selectedItems = doc.library.getSelectedItems();
if (!selectedItems.length) return;
var folder = fl.browseForFolderURL("Choose an output directory.");
if (!folder) return;
var i, t, sym, bmpName;
var count = 0;
for (i = 0; i < selectedItems.length; i++) {
sym = selectedItems[i];
if (sym.itemType != "bitmap") {
continue;
}
bmpName = sym.name.split("/").pop();
// strip original extension
t = bmpName.lastIndexOf(".");
if (t != -1 && ["jpg", "jpeg", "png", "gif", "bmp", "psd"].indexOf(bmpName.substr(t + 1).toLowerCase()) != -1) {
bmpName = bmpName.substr(0, t);
}
// do the thing
sym.exportToFile(folder + "/" + bmpName + "." + (sym.compressionType == "photo" ? "jpg" : "png"));
count++;
}
alert(count + " image(s) exported.");
}
exportLibraryImagesToFiles();
Copy link to clipboard
Copied
did you change itemType to "movie clip"?
Copy link to clipboard
Copied
Hi. Yes I tried to change it itemType for movie clip, but script does not work. Here is modified code.
function exportLibraryMovieClipsToFiles() {
var doc = fl.getDocumentDOM();
if (!doc) return;
var selectedItems = doc.library.getSelectedItems();
if (!selectedItems.length) return;
var folder = fl.browseForFolderURL("Choose an output directory.");
if (!folder) return;
var i, t, sym, mcName;
var count = 0;
for (i = 0; i < selectedItems.length; i++) {
sym = selectedItems[i];
if (sym.itemType != "movie clip") {
continue;
}
mcName = sym.name.split("/").pop();
// strip original extension
t = mcName.lastIndexOf(".");
if (t != -1 && ["jpg", "jpeg", "png", "gif", "bmp", "psd"].indexOf(mcName.substr(t + 1).toLowerCase()) != -1) {
mcName = mcName.substr(0, t);
}
// do the thing
sym.exportToFile(folder + "/" + mcName + "." + (sym.compressionType == "photo" ? "jpg" : "png"));
count++;
}
alert(count + " movie clip(s) exported.");
}
exportLibraryMovieClipsToFiles();
Copy link to clipboard
Copied
you still have errors, but the bottom line is the movieclip has no exportToFile method. ie, you'll need to convert it to a bitmap, first.