function CopyFile problem
bertseva
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"
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"
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!
FileNames[i]
). ;-)...
FileName=stringfromlist(i,FileNames)
HJ
February 16, 2016 at 02:21 pm - Permalink
For example, your sample code has no loop.
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
February 16, 2016 at 07:49 pm - Permalink
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.
February 17, 2016 at 01:56 am - Permalink
CopyFile/D/O/P=DATASCLA FileName as "..:Active"
use
CopyFile/D/O/P=DATASCLA FileName as ":Active"
February 17, 2016 at 05:34 am - Permalink
February 17, 2016 at 06:36 am - Permalink
http://www.igorexchange.com/node/6867
February 17, 2016 at 07:53 am - Permalink
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"
February 17, 2016 at 12:00 pm - Permalink
February 18, 2016 at 02:42 am - Permalink
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?
February 18, 2016 at 06:14 am - Permalink
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?February 18, 2016 at 06:55 am - Permalink
If you prefer to delete the folder contents rather than delete and recreate the folder itself, use
DeleteFile
along withIndexedFile
in a loop.February 19, 2016 at 05:59 am - Permalink
Thank you!
It helped.
March 2, 2016 at 08:22 am - Permalink