Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to Copy files

Status
Not open for further replies.

rianeiromiron

Programmer
Jul 1, 2001
151
GT
Hi all!!!

I have several files in several directories which, for some uknow reason were copied from a digital camera (through USB or whatever. So, the problem is some of the files have "invalid" names, which contains characters such as chr(8), chr(9) and so. If I copy those files manually, Windows can handle them just fine. But when I use the methods of copy in VFP known to me (COPY FILE) or those from WinApi, I allways get error messages. Here is an example of the methods I'v used, with no success

*!* Method 1.
*!* ParentFolder = "C:\Copia2"
*!* oShell = CreateObject("Shell.Application")
*!* oFolder = oShell.NameSpace(ParentFolder)
*!* oFolder.CopyHere("C:\Copia1\"+chr(11)+".XLS")

*fs = CreateObject("Scripting.FileSystemObject")
*fs.CopyFile("C:\Copia1\"+chr(11)+".XLS","C:\Copia2\"+chr(11)+".XLS",.T.) && The last parameter is for overwriting.

*COPY FILE GETFILE() TO "C:\Copia2\"+chr(11)+".XLS"

*!* FUNCTION TRYCOPY( OrigDir, NewDir )
*!* DECLARE INTEGER MoveFile IN WIN32API AS apiMoveFile STRING lpExistingFileName, STRING lpNewFileName
*!* RETURN 0<>apiMoveFile( OrigDir, NewDir )
*!* ENDFUNC

*!* I called the above function like this
*!* =TRYCOPY("C:\Copia1\"+chr(11)+".XLS","C:\Copia2\"+chr(11)+".XLS")


In all of the examples above, chr(11) is the invalid character.


Any clues on dealing with that? I DO NEED to copy those files.

Thanks.
 
(The reason I used chr(11) on the examples above, is because I that is one of the invlid chars I found on the filenames)
 
Have you tried to use the run command and shell to dos and do the copy?

Ali Koumaiha
Wireless Toyz
Farmington Hills, Michigan
 
Yes, D.O.S. works, and I know the hiding the DOS window stuff, however I do not want to use the DOS because I have to copy thousands of files (20 GB aprox) (due to security restrictions) one by one. Thanks
 
rianeiromiron,

Use GETFILE() like you are to see how VFP is seeing the name of the files with invalid characters in them... should give you a clue how to reference them and copy them to a new location using code.

Another thing to try is to stop attempting to dictate to VFP or Windows the names of the files... use sys(2000) or ADIR() to spin through all the files in a directory and move them to a new location.

Finally, MoveFile will move an entire directory, not just files... try just using it to move the files to a new location that way (this is of course assuming that you wish to move the entire contents of the directories in which they reside).

boyd.gif

 
Thank you Craig, but still no luck.

Using both, sys(2000) and ADIR gives me the following result,

A?B.XYZ

Where ? is the special character.

Thanks anyway.

 
What does DOS say the 8-3 name is for that same file?

A~B.XYZ <- Perhaps?

I'm thinking that you may be able to use the DOS short filename to get them. From DOS... CD to the directory where the files are and DIR to see the contents... do the files still have those weird characters in them?

boyd.gif

 
Yes. DOS sees the weird characters. For example, if I execute a DIR command, I can see the control character, for example a happy face or a music note. A?B.XYZ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top