Jump to content
Macro Express Forums

Append file names


Spareman

Recommended Posts

First off I'd like to apoligise if this has been answered before, but an hours google search came up with nothing.

 

I am writing a macro to imrpove some instrumentaton in my lab (postgrad) and I need it to do the following basically,

 

Run experiment (data is saved as Scan.txt)

Take saved data and append the filename with a "1" e.g. Scan1.txt

Run experiment again (new data set saved)

Take saved data and append the filename with a "2" e.g. Scan2.txt

etc.

 

for about 100 iterations. I think my limited experience is good enough to complete the macro except for the writing of filenames. What I have so far is something along the lines of :-

 

variable N1 is the iteration variable

 

 

Repeat (Repeat 100 times)

Run experiment

Renamefile "Scan.txt" to "Scan + %N1% .txt"

End repeat

 

Thats basically all I need however the code needed for line 3 is completely lost on me. Any help would be greatly appreciated.

 

Thanks,

Shane

Link to comment
Share on other sites

Hi Shane,

 

Although I'm no expert on this, I think that your problem is that the program sees N1 as a number, not as text. I did a little test myself, and could not get it to work as a number, but this did work.

 

Before the rename step, insert this step:

 

Variable Set String T1, choose Set Value Now, and for the value, put %N1%.

 

Then change your rename step to use %T1% instead of %N1% (and lose the plus sign so it reads Scan%T1%.txt)

 

This should do it for you.

 

David

 

edit: you may need to add a delay, or some query where it checks if the scan.txt file has been created. Otherwise, while the experiment is still running, the macro will move on and try to rename a file that isn't there yet.

Link to comment
Share on other sites

If I understand your message correctly, you need %N1% to increment by 1 each time you use it. You can do this directly in the Repeat statement itself (you'll see something like "store the counter into a variable"), or by including the statement "Variable Modify Integer %n1%: Increment" within the Repeat loop.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...