Save CSV wave to created directory

Hi,
I am trying to create a new folder within my Igor Experiment folder to save CSV files created from waves of data that I have. For some reason, when I execute these four lines of code, the program does not save on the last line. Instead, I get the error that the path name does not exist. How is this possible when I am specifically creating the directory that I will be using? I stepped through the code and ensured that the folders were in fact created.


String location = "C:\\Users\\John Hayward\\Documents\\"
String newCSVFolder = "2450 Trace_USB_SINGLE\\Data\\"
NewPath/C/O monthFolder, location + newCSVFolder + "January2014"
Save/J/P=monthFolder CSV as fileName
The exact error message is: Save error: "The system cannot find the specified path."
The /P flag takes the name of an Igor symbolic path. To read about Igor symbolic paths, execute:
DisplayHelpTopic "Symbolic Paths"

You can omit the /P and use a full path instead. Most Igor operations that work on files accept any of the following:

  • Full path to file

  • /P=<SymbolicPathName> <partial path to file relative to folder associated with <SymbolicPathName>>

  • /P=<SymbolicPathName> <simple file name>



Im sorry, but I don't understand how what I am doing is a full path. Am I not using a Symbolic path name in my code? Why is monthFolder not considered a symbolic path name?
Quote:
Am I not using a Symbolic path name in my code? Why is monthFolder not considered a symbolic path name?


My mistake. You are using a symbolic path name.

For debugging purposes I recommend that you create a test function as follows:

Function Test(fileName)
    String fileName
   
    String location = "C:\\Users\\John Hayward\\Documents\\"
    String newCSVFolder = "2450 Trace_USB_SINGLE\\Data\\"
    String fullFolderPath = location + newCSVFolder + "January2014"
    Print fullFolderPath
    String fullPath = fullFolderPath + "\\" + fileName
    Print fullPath
End


The use of the temporary string variables fullFolderPath and fullPath may provide a clue as to what is wrong with the paths. They also make the code easier to read and debug.

If that does not provide a clue, simplify the paths until you find something that works. That should reveal the cause of the problem.

Here is another test function that may prove useful for debugging:

Function Test(fileName)
    String fileName
   
    String location = "C:\\Users\\John Hayward\\Documents\\"
    String newCSVFolder = "2450 Trace_USB_SINGLE\\Data\\"
    String fullFolderPath = location + newCSVFolder + "January2014"
    Print fullFolderPath
    NewPath/C/O monthFolder, fullFolderPath
    GetFileFolderInfo/P=monthFolder
   
    String fullPath = fullFolderPath + "\\" + fileName
    Print fullPath
    GetFileFolderInfo fullPath
End

Oh my! I made a really stupid mistake. The fileName included the date, which had backslashes............ that was not good. Sorry for this, but thanks for helping me anyway. I really appreciate it.