Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: r603?

From   Dimitri Szerman <[email protected]>
To   statalist <[email protected]>
Subject   st: r603?
Date   Wed, 13 Oct 2010 09:32:49 +0100


I am using Stata to back up millions of files. Here's what I do

	! dir "mydir\*.csv" /a-d /b  > filelist.txt 		// create list of csv
files to be imported

	file open LIST using "filelist.txt", read
	file read LIST line
	while r(eof)==0 {
		copy "mydir\\`line'" "myotherdir", replace
		file read LIST line
	file close LIST

This works for many instances of "mydir" and "myotherdir". However,
sometimes, for reasons obscure to me, I get the following error

file XYZ.csv could not be opened.

Two things make this error message really strange to me. First, it
happens in the middle of the loop, ie, after having copied 1000s of
files to the destination. Secondly, if I type

copy "mydir\XYZ.csv" "myotherdir", replace

right after the error the operation carries through. Note, this line
is virtually identical to the one in the loop.

My Stata version is Stata11SE, and I'm running Windows XP and the
destination directory is a external Western Digital HD.

Just in case someone is wondering, I am using Stata to copy files
because it happens to be much more stable than DOS xcopy command. DOS
xcopy command would simply crash my computer, as I have millions of
files and xcopy appears to do bulky operations, while my Stata code
does one file at a time.

So, any thoughts on why I might be getting this error message and how
to go around it, would be much appreciated.

Many thanks,
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index