Write files to imac after SaveAs in macro

Help: I need to load NVDI images from directory, Convert them and save as… then be able to follow on and perform a “press Return keystroke” on my keyboard to continue the macro…

PS the Macro works extremely well apart from have to manually press RETURN each time… This is the function I want to automate… for 200 images = 200 Press Return’s.

I currently load all the files (select and drag and drop – which works really well). It is simple . And then run the macro

i = 0;
do {
  run("Split Channels");
  run("infraBlueNDVI");
  run("Calibration Bar...", "location=[Upper Right] fill=None label=Black number=5 decimal=0 font=12 zoom=2 overlay");
  saveAs("Jpeg");
  close();
  close();
  close();
  i = i + 1;
} while (i<=200);

You can use the save command with a path to avoid the file dialog, something like:

fileName=getTitle; 
saveAs("Jpeg", "C:\\Users\\files\\"+fileName);

or (Linux):

saveAs("Jpeg", "/home/user/"+fileName);

many thanks. Since your very prompt reply I copied the script and modified to to suit directories… I am using an Imac computer.
I now get this statement
")"; expected in line 11.
();


I have tried all the permutations I can think of, including using the Linux versions
I am mystified… help.


i = 0;
   do {
run("Split Channels");
run("infraBlueNDVI");
run("Calibration Bar...", "location=[Upper Right] fill=None label=Black number=5 decimal=0 font=12 zoom=2 overlay");

fileName=getTitle; 
saveAs("Jpeg", "\Users\\user\Desktop\\Batch processor\\”+fileName);
close();
close();
close();
  i = i + 1;
   } while (i<=200);

Well it looks like you put the wrong path into the save command.

On MacOSX it should look like:

saveAs(“Jpeg”, “/Users/user/Desktop/Batch processor/”+fileName);

You could also use a file seperator function to make it platform independent, see:

http://imagej.1557.x6.nabble.com/file-path-Mac-versus-Windows-td3682325.html

Please control your path!

Hi there. I also tried that format earlier and just a moment ago as well…(saveAs(“Jpeg”, “/Users/user/Desktop/Batch processor/”+fileName); …and still the same error appears.

I will pursue the other option you gave me. Thank you for your help . (I never had this issue with Windows!! - mainly with Excel macro in that case)
Frank

In the code you posted, there’s a wrong quotation character that was probably introduced by some auto-correction function doing the wrong thing, likely in your word processing software or mail client.

I modified your post above to include syntax highlighting, so this error can easily be spotted by the red color of the following lines. I recommend using the Script Editor in Fiji, it also has syntax highlighting and helps spotting this kind of formatting errors.

Thank you I will try that tomorrow.
At the moment, using my original script
SaveAs(“Jpeg”); Does work.

I have to open the target directory and place a paper weight on th RETURN KEY. For the duration of the run

This works fine for all my loaded original images ( up to 200 at a time)

I then, separately, batch process these into a video with delay frame rate for analysis.
Frank

Finally cracked it… All I had to do was insert mydir = getDirectory… it runs brilliantly… Thanks to everyone who contributed to getting my brain on track… Sometimes things are just under your nose…
PS: I use manual upload at the moment… I will add that step later…

// Manually load images for directory
//Select target directory and run
  
  mydir = getDirectory("");  
  
  i = 0;
   do {
   run("Split Channels");
run("infraBlueNDVI");
run("Calibration Bar...", "location=[Upper Right] fill=None label=Black number=5 decimal=0 font=12 zoom=2 overlay");

saveAs("Jpeg", mydir+getTitle);
close();
close();
close();
    i = i + 1;
   } while (i<=200);

// I have found this whole excersize extremely useful.
//The directory format is for an AppleMac. (Linux i think). All the original images start with IMA - which is use to grab the //files from the input folder.

//I can now open all the files from a chosen directory and using images to stack etc do all the work autonomously and //save the files in the new format to another on the fly chosen directory. this output bins the original title and just gives a //numerical sequence that I port into a timelapsed video maker. I hope this can be useful for others.

mydir = getDirectory("");  

run("Image Sequence...", "open=[/Users/user/Desktop/untitled folder] file=IMA sort use");
run("Split Channels");
selectWindow("untitled folder (green)");
close();
selectWindow("untitled folder (red)");
close();
run("infraBlueNDVI");
run("Calibration Bar...", "location=[Upper Right] fill=None label=Black number=5 decimal=0 font=12 zoom=2 overlay");
run("Virtual Stack...", "output=JPEG text1=[ ] save=[ mydir+00001.jpg]");
close();
selectWindow("untitled folder (blue)");
close();
close();