\* --------------------------------------------------------------------
\* STN Express Script
\* Name: filenaming.sc
\* Description: The script determines whether a given file exists in
\* the Uscripts folder. If a file already exists, the
\* script adds a sequential number to the file name. The
\* script thus prevents from accidentally deleting
\* existing output or transcript files.
\* Authors: Christoph Neuhaus, ETH Zurich
\* Andreas Litscher, InfoLit Infobroker GmbH, Bern
\* Date: 02.01.2008
\* Version: 1.0
\* --------------------------------------------------------------------
\* Path of your STN Express installation
\* (e.g. "c:\\STNEXP" or "c:\\Program Files\\STNEXP")
_stnepath = "c:\\STNEXP"
\* Path of your output file
_outputfile = "_stnepath"+"\\Uscripts\\output.txt"
\* Initialize sequential number
_i = 1
@rename
\* Check whether a file exists
exists <_outputfile>
\* If a file already exists, add a sequential number to the file name
if (_$filerror = 0)
begin
_i = _i + 1
_outputfile = "_stnepath"+"\\Uscripts\\output"+"_i"+".txt"
goto @rename
end
\* Open file for testing
capture on <_outputfile>
capture off <>
if (_$filerror = 1)
begin
goto @outerror
end
\* Write output to file
echo "hello world"
goto @end
\* Error message
@outerror
echo ""
echo "Error: output file not found"
echo ""
goto @end
@end
\* Exit
echo ""
echo "****** END OF SCRIPT ******"
echo ""
exit
\* --------------------------------------------------------------------
Hellen