Login  Register

appending text to a txt file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

appending text to a txt file

John Alexander-7
Hello group,

I am batch processing a ton of files - and I am writing the name of each
file processed into a log file.  I am also recording which files threw
an exception in an error log file.

My approach was to just open the log file, append the information, then
close it.

I believe the two snippets of code below were working just fine a few
months ago - but now they seem to overwrite the file rather than append
to it.

Can someone confirm that this is happening - or is there a mistake in
how I am trying to append to a text file.

I want the file to be appended before and after each image processed so
as to help me identify corrupted files which crash the macro.

Thanks,

John



//begin snippet one
if ((ImageLogFile==true)&&(MasterSave==true)) {
        imagefilelog=File.open(dir+File.separator+"ImageLog.txt");
        print(imagefilelog,SLDdir+"\t"+SLDname+"\n");
        File.close(imagefilelog);
}
//end


and


//begin snippet two
if (isOpen("Exception")) {
        selectWindow("Exception");
        run("Close");
        logfile=File.open(dir+File.separator+"Error_Log.txt"+"\n");
        print(logfile,"SLD: "+SLD+":   "+SLDdir+SLDname+" threw an exception");
        File.close(logfile);
}
//end