find included originals

find included originals


/* JAlbum tool to pictures where the original picture is included in the project. 
 * Place this file in the tools folder of your jAlbum directory. 
 * To start this program select the "Tools" pull down menu in jAlbum, then select "External Tools" and then select this program.
 */

import se.datadosen.jalbum.*;
import se.datadosen.explorer.*;
import se.datadosen.util.IO;
import java.io.*;

int repaired = 0;

void findIncludedOriginals(AlbumObject folder) throws IOException {
	File link;
	String path;
	ArrayList all = folder.getChildren();
	
	for (AlbumObject ao : all) {

		if ( ao.isIncludeOriginal()) {
			link = ao.getFile();
			System.err.println(link);
			repaired++;
		}
		if ( ao.isFolder() ) {
			findIncludedOriginals(ao);
		}
	}
}
	
void processAlbum() {
	System.err.println("Starting search for included originals");
	try {
		
		findIncludedOriginals(window.albumExplorer.getRootFolder());
	} catch(IOException e) {
		System.out.println(e);
	}
	System.err.println("Search for included originals finished");
	JOptionPane.showConfirmDialog(window, new Object[] { 
			new JLabel(((repaired > 0)? (repaired.toString() + " included originals have been found. See java system console \"F7\" for details.") : "No included originals have been found."))
		},
		"Finished searching", JOptionPane.DEFAULT_OPTION);
}

// Execution starts here

processAlbum();



Usage: copy the text above in a file with the extension ".bsh". Put this file in the tools folder of jAlbum. After next start of jAlbum, you will find the file in the Tools -> external Tools section.