• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Export selected Movie Clips in library to PNGs and keep the name of the MC.

Community Beginner ,
Feb 14, 2024 Feb 14, 2024

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

Views

146

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2024 Feb 14, 2024

Copy link to clipboard

Copied

did you change itemType to "movie clip"?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 19, 2024 Feb 19, 2024

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2024 Feb 19, 2024

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines