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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COPY TO command results in all lower case 1

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,788
10
38
JP
Hi All,
Ok, I'm having a serious brain seizure moment with COPY TO.
No matter what I do, when I send the file to a filename using COPY TO (Such as COPY TO MyFile2024.XLS XL5) the result is myfile2024.xls in the directory the file is written to.

Am I missing some switch or setting for this? Is there any way to get/keep the case sensitivity of my file names?
I don't recall this issue with other methods I've used to write out filenames in VFP, it is just COPY TO that is the issue.


Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCAP, CDCP, CDCS, CDCE, CTDC, CTIA, ATS, ATD

"I try to be nice, but sometimes my mouth doesn't cooperate.
 
Hi

I would try this type of code, having removed the existing file first

Code:
COPY TO ("D:\$INCOMING\TEK-TIPS\MyFile.xls") XLS

To be honest, it's the removal of the original / existing file that counts though B-)

It's a Windows feature, it tries to maintain the filename and creation date for existing files.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
I have a feeling that the FileSystemObject within Windows Scripting Host has a way of copying files while preserving the original case, but I can't find any mention of it now in my notes. It might be worth a quick glance at the documentation.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I *think* the OP is trying to avoid the case remaining the same as the original file - rather than deliberately maintaining the original case,
he wants to use the case he specifies.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
Tore,

The second chunk of code in Sergey's article was exactly what I was thinking of when I referred to the FileSystemObject. It looks like it should meet Scott's requirements.

(Good to see you back here, by the way.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks guys, I had a look at the link Tore provided (and I'm very glad to see you back again too!).
The problem is these are both geared to copy/move of a file. And I don't see how they can be used during a file write using the COPY TO command in VFP, because it's performing some other "magic" to transform the data in a cursor to an Excel file.

I tried to rename initially but that also yielded the same, however Tore's option may allow me to do a rename with the copy, and get the case I'm looking for.
So annoying that they did this. Doesn't make sense because you have to force it all to lower to get this result, and there is no need even traveling all the way back to DOS 2.0 for this to be necessary.
(Sorry, ranting, it's been one of those days...)


Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCAP, CDCP, CDCS, CDCE, CTDC, CTIA, ATS, ATD

"I try to be nice, but sometimes my mouth doesn't cooperate.
 
Scott

Simply delete the existing file BEFORE the copy and VFP will use the case settings you specify

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
You lost me Griff, how can I delete the file before it is copied and still copy it?

Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCAP, CDCP, CDCS, CDCE, CTDC, CTIA, ATS, ATD

"I try to be nice, but sometimes my mouth doesn't cooperate.
 
Sorry Scott

If I do a copy to with the format MyFile.xls and there is no existing MyFile.xls already, I get exactly that MyFile.xls

If however myfile.xls already exists, I end up with myFile.xls not MyFile.xls

So, to ensure I get MyFile.xls, I simply delete myfile.xls before I do the copy.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
Just been doing a bit of experimenting - but not much further forward.

1. Created a file called MyFile2024.XLS (this is just an empty file).

2. In VFP:

Code:
USE Master
COPY TO MyFile2024.XLSX TYPE XL5

3. The output file was named myfile2024.xlsx - not what you want.

4. Ran this code:

Code:
lcFileName = "Master.dbf"
lcCopyFileName = "MyFile2024.XLS"
oFSO = CreateObject("Scripting.FileSystemObject")
llOverWrite = .T.
oFSO.CopyFile(lcFileName, lcCopyFileName, llOverWrite)

5. The output filename was named MyFile2024.XLS - which is what you want.

But while the case was correctly preserved, it's no practical use, as the XLSX file is just a copy of the DBF - no conversion to Excel.

I'm not sure what to suggest next.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Scott, I can't reproduce what you experience.

When I create a new file with COPY TO, which I assume you also do, the name is cased just as I write it in the COPY TO command, no matter if I use the longhand full path, name expression or first CD into the target directory and use the straight forward command with just the filename, even unquoted.

If I overwrite an existing file, and confirm the security warning to overwrite the file (or have SET SAFETY OFF) the file name is kept as is, i.e. overwriting recycles the TOC entry in the file system, VFP doesn't overwrite the filename, only the content of the file.

What file system is your target directory? My observations are done on an NTFS formatted drive, which is the "home" file system for VFP, I didn't test Fat32 or exFat, maybe in those file systems VFP does what you see. But the only reason I see in my experiments is what Griff already pointed out multiple times: An existing file with same name is actually not overwritten in the full sense of overwriting, i.e. creating a brand new file that replaces the old one.

A NAS drive or external drive might also differ in that aspect, but generally speaking, using VFP on NTFS yields no forcing of lowercase names, not from VFP.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top