function CopyFile problem

Please, tell me what do I do wrong?

Here's an example from Igor help file on the function copyfile:

// Copy a file into subfolder using the original name (using /P)
CopyFile/D/P=myPath "afile.txt" as ":subfolder"
Print S_Path    // prints "Macintosh HD:folder:subfolder:afile.txt"


Here's what I do:

    String PreCursorFileNames
    NewPath /O /M="Select Dir containing the data" DATASCLA
        FileNames=IndexedFile(DataSCLA,-1,"????")
    Make /o/t/n=(1) FileName=stringfromlist(i,FileNames)

    CopyFile/D/O/P=DATASCLA FileName as ":Active"  


It does not work - for each i in my loop it opens a Save dialogue window and asks where to save file.

Thank you in advance!
Maybe you might want to use a string instead of a one entry text wave (or at least a single entry from FileNames -- FileNames[i]). ;-)
string FileName
...
FileName=stringfromlist(i,FileNames)


HJ
Let us see the whole routine, not just a piece.

For example, your sample code has no loop.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Thank you for your replies!
Basing on them I've tried more, and finally it works - the program is the same as before, only I created the path "Active", as the help file says. The directory has to exist or the function will ask for it. My problem was that I was afraid to put the directory inside the same directory as my files, because I thought that IndexedFile will read it as one of the files.
So I was creating it later, and it did not work.

Now I have a new question. How can I address a relative directory? This does not work:

CopyFile/D/O/P=DATASCLA FileName as "..:Active"

Does not work, but the function now behaves differently than before. Before, when the directory did not exist, it was proposing the name "Active" for the file being saved. Now it proposes the right name, but asks for directory to put it.
Instead of
CopyFile/D/O/P=DATASCLA FileName as "..:Active"

use
CopyFile/D/O/P=DATASCLA FileName as ":Active"

bertseva wrote:
This works, but I want the directory one step upper. How can I set this?


In that case, if the target directory is directly above the current one, use

CopyFile/D/O/P=DATASCLA FileName as "::"

If the target directory is off the same one up directory and at the same level as the current directory, use

CopyFile/D/O/P=DATASCLA FileName as "::Active"

This will move up one level then move down one level to the directory named "Active".

Run the following from the Command Window to learn more about data folder syntax

DisplayHelpTopic "Data Folder Syntax"
Thank you very much!

jtigor wrote:
bertseva wrote:
This works, but I want the directory one step upper. How can I set this?


In that case, if the target directory is directly above the current one, use

CopyFile/D/O/P=DATASCLA FileName as "::"

If the target directory is off the same one up directory and at the same level as the current directory, use

CopyFile/D/O/P=DATASCLA FileName as "::Active"

This will move up one level then move down one level to the directory named "Active".

Run the following from the Command Window to learn more about data folder syntax

DisplayHelpTopic "Data Folder Syntax"

[quote=KurtB]Does this help?

http://www.igorexchange.com/node/6867[/quote]

No, because it deals with the folders of the experiment, while I wanted the file folders on the disk.

Could someone recommend me the help file about the dealing with the file structure on the disk?
Now I need to empty the directory before writing to it.

I have found DeleteFolder, but it makes a double check if I'm sure that I want to delete it - opening a dialogue.

Now I create the directory using the /C key in NewPath. Is there a more direct way?

bertseva][quote=KurtB]Does this help?<br> <br> <a href="http://www.igorexchange.com/node/6867[/quote">http://www.igorexchange.com/node/6867[/quote</a> wrote:


No, because it deals with the folders of the experiment, while I wanted the file folders on the disk.

Could someone recommend me the help file about the dealing with the file structure on the disk?
Now I need to empty the directory before writing to it.

I have found DeleteFolder, but it makes a double check if I'm sure that I want to delete it - opening a dialogue.

Now I create the directory using the /C key in NewPath. Is there a more direct way?

Sorry - my mistake.

A quick look at the help DisplayHelpTopic("DeleteFolder") says that the asking permission behaviour can be altered using Miscellaneous Settings. This may help? - I'm not sure if you can change this in code?
bertseva wrote:

Could someone recommend me the help file about the dealing with the file structure on the disk?
Now I need to empty the directory before writing to it.

I have found DeleteFolder, but it makes a double check if I'm sure that I want to delete it - opening a dialogue.

Now I create the directory using the /C key in NewPath. Is there a more direct way?


If you prefer to delete the folder contents rather than delete and recreate the folder itself, use DeleteFile along with IndexedFile in a loop.
jtigor wrote:


If you prefer to delete the folder contents rather than delete and recreate the folder itself, use DeleteFile along with IndexedFile in a loop.


Thank you!
It helped.