This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 9 - Pages: 1 - Last Post: 11-Nov-2015 23:33 Last Post By: davidekholm
burkins

Posts: 25
Registered: 02/02/09
Manually add folder via command line
Posted: 03-Dec-2014 03:13
 
  Click to reply to this thread Reply
I have jAlbum set to "Exclude new images by default". Handy feature, because it keeps new folders from accidentally being pushed up to my website.

I produce new builds of my jAlbum via command-line (which is a wonderful feature).

I would like a way to tell jAlbum (via command-line) to include a new folder in the published album. Without that feature, the folder and images always end up with a "-" in albumfiles.txt

The only solution I can think of: Run jAlbum so that the folder/images get added to albumfiles.txt (with a leading hypen for exclusion). Then manually process the albumfiles.txt file myself via grep etc. Possible, but seems rather awkward. Seems like there should be a flag to "include" a specific new folder.

Thanks for your consideration !
-Chad
RobM

Posts: 4,265
Registered: 08/04/06
Re: Manually add folder via command line
Posted: 04-Dec-2014 02:02   in response to: burkins in response to: burkins
 
  Click to reply to this thread Reply
I don't know of an existing command line way of doing it, all the commands are listed here http://jalbum.net/help/en/Running_jAlbum_from_the_command_line

If you only ever temporarily exclude new folders, that is you don't have permanently excluded folders/files like a theme image etc. then you could do it with a .bsh file saved as an external tool. Your command line would then need to call the external tool by, for example, adding -runTool "tools/Include excluded files.bsh".

An example tool which will include all excluded folders/files is attached, it could be modified to not include specific folders/files if needed.
/* Batch move excluded files. David Ekholm, modified by RobM 2014*/
import se.datadosen.jalbum.*;
msg = "This tool will batch include all excluded files in the project";
int answer = JOptionPane.showConfirmDialog(window, msg, "Batch move excluded files", JOptionPane.OK_CANCEL_OPTION);
if (answer != JOptionPane.OK_OPTION) return;
processAllFiles(AlbumObject root) {
		for (AlbumObject ao : root.getChildren()) {
			Category cat = ao.getCategory();
			vars = ao.getVars();
			name = vars.get("fileName");
			if(cat == Category.folder) {
				processAllFiles(ao);
			}
			if (!ao.isIncluded()) {
			//if specific folders/files are not to be included then change the line above to e.g
			//if (!ao.isIncluded() && !name.equals("folder name or file name and extension")) {
				ao.setIncluded(true);
			}
		}
}
//ArrayList excludeList = new ArrayList();
processAllFiles(rootFolder);
window.albumExplorer.refreshAction.actionPerformed(null);

Would that help? If not someone might have a better solution.

Edited by: RobM on 11-Nov-2015 22:33
davidekholm

Posts: 21,298
Registered: 10/18/02
Re: Manually add folder via command line
Posted: 04-Dec-2014 15:09   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
I think an external tool that includes a specific folder is a good idea. The problem is likely "only" how to pass the folder name as parameter to the external tool. You could probably do that via a System property, so call jAlbum like this for instance:
java -Xmx400M -DincludeFolder="FolderToInclude" -jar JAlbum.jar -directory=path/to/directory -runTool "tools/includeFolder.bsh"
The "includeFolder.bsh" tool could then pick up the name of the folder to include by a simply System.getProperty("includeFolder") call.
RobM

Posts: 4,265
Registered: 08/04/06
Re: Manually add folder via command line
Posted: 07-Dec-2014 02:24   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
I think an external tool that includes a specific folder is a good idea. The problem is likely "only" how to pass the folder name as parameter to the external tool. You could probably do that via a System property, so call jAlbum like this for instance:
java -Xmx400M -DincludeFolder="FolderToInclude" -jar JAlbum.jar -directory=path/to/directory -runTool "tools/includeFolder.bsh"
The "includeFolder.bsh" tool could then pick up the name of the folder to include by a simply System.getProperty("includeFolder") call.
When you are feeling better, and if you think it worth doing then I suspect it requires a bit more work. Presumably the 'includeFolder' system property would be a string, not an object and you need to convert it to a file object? Also, to make it work generally, as a menu option for GUI users, you would need to include a prompt for the folder name or ask them to navigate to the required folder. Possibly also asking/testing for a system property that covers recursive calls for sub folders or not?

I don't use the command line, in fact I can't get it to run properly on my Mac. In terminal, having navigated to the Java folder (Applications/jAlbum.app/Contents/Java) and run the command java -Xmx400M -jar JAlbum.jar -projectFile=/Users/robert/Pictures/jAlbum/test/test.jap -Djava.awt.headless=true it reports an error that the image directory specified in the project is not a folder (I tried it with and without the last switch).

Anyway, unless you see a need for it or the OP asks for it, I think it is currently beyond me trying to get it to work as suggested.
davidekholm

Posts: 21,298
Registered: 10/18/02
Re: Manually add folder via command line
Posted: 08-Dec-2014 12:41   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
Check the contents of that .jap file and inspect the "directory=" property. That's the "image directory". Ensure the path pointed out there is correct. Also, any -D options need to be before the -jar option.
RobM

Posts: 4,265
Registered: 08/04/06
Re: Manually add folder via command line
Posted: 08-Dec-2014 23:31   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
The path to the image directory is correct, it is a test project that I normally run from the GUI.
The image directory is at /Users/Robert/Pictures/jAlbum/test/
The images are links, not actual files.
burkins

Posts: 25
Registered: 02/02/09
Re: Manually add folder via command line
Posted: 08-Dec-2014 23:44   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
Thanks so much for the spirited replies to my question. I'm rather handy with both command-line and scripting, but admittedly, have never used the external tool feature of jAlbum.

Since I use jAlbum exclusively from the command-line, this is likely worth my time. I'll let you know how I make out, and thanks for the example script.

-Chad Burkins
davidekholm

Posts: 21,298
Registered: 10/18/02
Re: Manually add folder via command line
Posted: 09-Dec-2014 09:31   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
The path to the image directory is correct, it is a test project that I normally run from the GUI.
The image directory is at /Users/Robert/Pictures/jAlbum/test/
The images are links, not actual files.

Truly odd. I've ran a couple of album builds from various projects via the command line on my Mac using jAlbum 12.3. No errors about the image directory not pointing towards a valid directory. Try using another album project.
RobM

Posts: 4,265
Registered: 08/04/06
Re: Manually add folder via command line
Posted: 10-Dec-2014 02:08   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
I found an unwanted '=' at the start of the project file path, removing that gets rid of the original error and works with Minimal skin. Then, foolishly, I tried one of my actual projects using my Notables skin and got a much more interesting response!
In Terminal, having navigated to the Java directory within the jAlbum application package (Roberts-MBP:Java robert$), I enter
java -Xmx400M -Djava.awt.headless=true -DincludeFolder="top folder" -jar JAlbum.jar -projectFile /Users/robert/Pictures/jAlbum/home/photos/photos.jap
And get the following messagecode
java -Xmx400M -Djava.awt.headless=true -DincludeFolder="top folder" -jar JAlbum.jar -projectFile /Users/robert/Pictures/jAlbum/home/photos/photos.jap
jAlbum v12.3 started in console mode
Preparing album engine with settings from /Users/robert/Library/JAlbum/skins/Notables/headless-settings.jap
javax.script.ScriptException: bsh.TargetError: Sourced file: inline evaluation of: ``/** * This script is run everytime an album is generated. * It adds camera d . . . '' : Typed variable declaration : Method Invocation nao.getVars : at Line: 620 : in file: inline evaluation of: ``/** * This script is run everytime an album is generated. * It adds camera d . . . '' : nao .getVars ( )

Target exception: java.lang.RuntimeException: Cannot register variables for index.htt
in inline evaluation of: ``/** * This script is run everytime an album is generated. * It adds camera d . . . '' at line number 620
at bsh.BshScriptEngine.evalSource(BshScriptEngine.java:97)
at bsh.BshScriptEngine.eval(BshScriptEngine.java:61)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at se.datadosen.jalbum.AlbumBean.doProcessExpression(AlbumBean.java:2091)
at se.datadosen.jalbum.AlbumBean.processExpression(AlbumBean.java:2075)
at se.datadosen.jalbum.AlbumBean.processScript(AlbumBean.java:2030)
at se.datadosen.jalbum.AlbumBean.prepareMakeAlbum(AlbumBean.java:2469)
at se.datadosen.jalbum.AlbumBean.makeAlbum(AlbumBean.java:2255)
at se.datadosen.jalbum.AlbumBean.smartMakeAlbum(AlbumBean.java:2237)
at se.datadosen.jalbum.JAlbumConsole.<init>(JAlbumConsole.java:104)
at se.datadosen.jalbum.JAlbum.main(JAlbum.java:323)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at se.datadosen.jalbum.Main.main(Main.java:36)
Caused by: java.lang.RuntimeException: Cannot register variables for index.htt
at se.datadosen.jalbum.AlbumObjectImpl.getVars(AlbumObjectImpl.java:2167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at bsh.Reflect.invokeMethod(Reflect.java:146)
at bsh.Reflect.invokeObjectMethod(Reflect.java:79)
at bsh.Name.invokeMethod(Name.java:859)
at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
at bsh.BSHVariableDeclarator.eval(BSHVariableDeclarator.java:86)
at bsh.BSHTypedVariableDeclaration.eval(BSHTypedVariableDeclaration.java:84)
at bsh.BSHBlock.evalBlock(BSHBlock.java:130)
at bsh.BSHBlock.eval(BSHBlock.java:80)
at bsh.BSHBlock.eval(BSHBlock.java:46)
at bsh.BSHEnhancedForStatement.eval(BSHEnhancedForStatement.java:80)
at bsh.BSHBlock.evalBlock(BSHBlock.java:130)
at bsh.BSHBlock.eval(BSHBlock.java:80)
at bsh.BshMethod.invokeImpl(BshMethod.java:362)
at bsh.BshMethod.invoke(BshMethod.java:258)
at bsh.BshMethod.invoke(BshMethod.java:186)
at bsh.Name.invokeLocalMethod(Name.java:918)
at bsh.Name.invokeMethod(Name.java:804)
at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:75)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
at bsh.BSHBlock.evalBlock(BSHBlock.java:130)
at bsh.BSHBlock.eval(BSHBlock.java:80)
at bsh.BSHBlock.eval(BSHBlock.java:46)
at bsh.BSHIfStatement.eval(BSHIfStatement.java:48)
at bsh.Interpreter.eval(Interpreter.java:672)
at bsh.Interpreter.eval(Interpreter.java:766)
at bsh.Interpreter.eval(Interpreter.java:755)
at bsh.BshScriptEngine.evalSource(BshScriptEngine.java:89)
... 15 more
Caused by: java.lang.RuntimeException: Error processing /Users/robert/Pictures/jAlbum/home/photos/index.htt
at se.datadosen.jalbum.AlbumBean.registerVariables(AlbumBean.java:1942)
at se.datadosen.jalbum.AlbumObjectImpl.getVars(AlbumObjectImpl.java:2165)
... 49 more
Caused by: java.lang.RuntimeException: Custum UI scripting error
at se.datadosen.jalbum.AlbumBean.registerVariables(AlbumBean.java:1879)
... 50 more
Caused by: bsh.InterpreterError: Error in class initialization: bsh.TargetError: Typed variable declaration : Object constructor : at Line: 26 : in file: inline evaluation of: `` // Check the skin's properties file for fullSiteSupport File skinDescFile = n . . . '' : new JSmartTextArea ( "#pageContent{ \n\n}" , 15 , 30 )

Target exception: java.lang.ExceptionInInitializerError

at bsh.ClassGeneratorUtil.initInstance(ClassGeneratorUtil.java:968)
at contactPrintSheetUI.<init>(BeanShell Generated via ASM (www.objectweb.org))
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at java.lang.Class.newInstance(Class.java:433)
at se.datadosen.jalbum.AlbumBean.registerVariables(AlbumBean.java:1862)
... 50 more
Caused by: bsh.TargetError: Typed variable declaration : Object constructor : at Line: 26 : in file: inline evaluation of: `` // Check the skin's properties file for fullSiteSupport File skinDescFile = n . . . '' : new JSmartTextArea ( "#pageContent{ \n\n}" , 15 , 30 )

Target exception: java.lang.ExceptionInInitializerError

at bsh.BSHAllocationExpression.constructObject(BSHAllocationExpression.java:132)
at bsh.BSHAllocationExpression.objectAllocation(BSHAllocationExpression.java:114)
at bsh.BSHAllocationExpression.eval(BSHAllocationExpression.java:62)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
at bsh.BSHVariableDeclarator.eval(BSHVariableDeclarator.java:86)
at bsh.BSHTypedVariableDeclaration.eval(BSHTypedVariableDeclaration.java:84)
at bsh.BSHBlock.evalBlock(BSHBlock.java:130)
at bsh.ClassGeneratorUtil.initInstance(ClassGeneratorUtil.java:966)
... 57 more
Caused by: java.lang.ExceptionInInitializerError
at se.datadosen.component.JSmartTextArea.makeSmart(JSmartTextArea.java:49)
at se.datadosen.component.JSmartTextArea.<init>(JSmartTextArea.java:32)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at bsh.Reflect.constructObject(Reflect.java:574)
at bsh.BSHAllocationExpression.constructObject(BSHAllocationExpression.java:125)
... 65 more
Caused by: java.awt.HeadlessException
at sun.awt.HeadlessToolkit.getMenuShortcutKeyMask(HeadlessToolkit.java:234)
at se.datadosen.component.JSmartTextComponentSupport.<clinit>(JSmartTextComponentSupport.java:49)
... 73 more
codeUsing jAlbum 12.3 Java 1.8, 64 bit (java.runtime.version 1.8.0_25-b17, os.version 10.10.1). A good job I don't use the command line. Anyway, I can now play around with the command line with other skins if need be.
davidekholm

Posts: 21,298
Registered: 10/18/02
Re: Manually add folder via command line
Posted: 10-Dec-2014 11:18   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
Thanks for reporting. Its obviously so that custom web pages aren't processed well from the command line.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums