Save as Image sequence part of macro -> save to variable directory

Hey, this is my first ever programming question in a forum, so exciting :smiley:
I am just starting off with coding, and I decided that attempting to automate a very long and tedious pre-processing procedure I have to do is a good start, but I have hit a rock that I can’t find a solution to from the online forums (even though I tried many things!) …

One of the first steps of my macro is saving a video as image sequence.
Using the Recorder and selecting that I want the names of the image sequence to be from the original file name (RGB.tif), I got this line:

run("Image Sequence… ", “format=TIFF use save=C://User/Desktop/test/RGB0000.tif”);

Earlier in the code, I have already set a variable for the path I want to save the sequence to (lets call it just Dir here), and I have been trying to simply alter the code to use this variable path and save the image sequence in the way I want it to.
I have tried various versions of this, based on all the forums I read, and one of two things happen:
I either get un “undefined variable” error (I found out the file name (RGB0000.tif, see below) has to be in " " to solve this)
or, most recently,
I get a pop up window asking me to choose the directory the image sequence will be saved, even though I have already defined it in the command:

run(“Image Sequence… “, “format=TIFF use save = [”+Dir+“RGB0000.tif”+”]”);

Does anyone have any ideas what the issue might be? I found all of the quotation marks and plus signs so confusing in Macro language, for defining new or variable directories and filenames…

If you post more of your code I might be able to help more.
The macro language is based on strings inside of those parentheses.

Adding two strings together joins them…so:

"hello" + "world"



If you create a variable:

Dir = "C://User/Desktop/"

you can add it to another string

Dir + "RGB.tif"



I noticed in this command:

that there is a space on either side of the equals sign. That shouldn’t be there.

1 Like

I removed the spaces in the equal sign and it works now …
Thank you!! I didn’t realise with the macro language the spaces matter so much, I should probably do some basic tutorial before I go straight into making macros…
Thanks again!

Glad to help.

There is a lot of info out there to help you get started. I’d look at these two to start: