Page 1 of 1

Creating Dynamic File Names Within a Do Loop

Posted: Tue Aug 12, 2008 1:17 pm
by Gregory
Not sure what I'm doing wrong here. I'd like to save results on each iteration of a Do loop and append the iteration number, i, to each file name. But when I run this code, I am prompted for a location to save, and the forward slashes in my file path have been converted to hyphens.

Code: Select all

declare string theFilePath
declare string longFileName

compute theFilePath = "/Users/gregory/Documents/Folder A/"

do i=1,5

* Some stuff goes here

compute longFileName = theFilePath + "My File" + i + ".xls"
open copy &longFileName
copy(format=xls,org=col) theStart+i theEnd+i hhs

End do i

Posted: Wed Aug 13, 2008 11:58 am
by TomDoan
It sounds as if that path doesn't exist. (COPY will create a new file in an existing folder, but it won't create a new folder). The -'s seem to be the Mac OS X file dialog's method of dealing with input file names with /'s in them. I haven't been able to find a good description of why it does that. At any rate, it looks as if having a path to a valid folder will avoid the problem.

Posted: Wed Aug 13, 2008 4:20 pm
by Gregory
TomDoan wrote:It sounds as if that path doesn't exist.
You're absolutely right. Missing sub-folder. Thank you, Tom.

Gregory