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

File Name - Case Question

Status
Not open for further replies.

JRB-Bldr

Programmer
May 17, 2001
3,281
US
For quite a while now I have been putting up with a Filename Case issue. It has been annoying and I'd like to finally get it resolved.

Example:
Code:
 SELECT MyTable
 COPY TO "C:\TEMP\TEMP.XLS" XL5

Results in a file with the following name and case.
temp.xls in the C:\Temp directory.

Even attempting the following will not change the case.
Code:
 RENAME "C:\temp\temp.xls" TO "C:\temp\TEMP.XLS"

Still results with the following name and case.
temp.xls in the C:\Temp directory.

What does it take to get the case correct regardless if it is intentionally UPPER, LOWER, or Mixed Case?

Thanks,
JRB-Bldr
 
Unfortunately because of VFPs DOS (and Windows 3.x) legacy, it doesn't have ANY native commands that are filename case sensitive. (See the only 'exception' to this statement I'm aware of below in the Note.) If you want to create/rename files that maintain a specific casing, you need to use WSH or the newer Win32 API calls. Here is some code written and posted by Anders Altberg
Code:
*:* Show Filenames with case preserved [vs. ADIR()]
*:* As filenames are case-insensitive in Windows and NT,
*:* all file formats, upper case is as correct as lower
*:* or whatever. You can use the FileSystemObject to
*:* get the names as Explorer shows them.

path = "C:/mydata/"
ofs=create('scripting.filesystemobject')
n = ADIR(arr,path+"*.*")
FOR ii = 1 TO n
 ? ofs.getfile(path+arr[ii,1]).name
NEXT
Note: This is an old example, I just checked and since VFP 7.0, ADIR() actually has a 4th parameter that can specify the case returned - including 8.3 format!

Rick
 
I am coming back on this question because the issue of VFP7 writing/saving/copying files with only lower case names has raised its head again.

The users are beginning to complain again.

I am hoping that someone might have an answer.
* Is there a Windows Scripting solution?
* Some other non-native, but VFP automatable solution?

Any suggestions/advice would be most appreciated.

Thanks,
JRB-Bldr
 
Well I guess that I found my own answer....

By using the follows Windows Scripting I was able to change the Case of the filename

Code:
mcOriginal = "C:\Temp\ab_list.dbf"
mcNewCase = "C:\Temp\AB_List.dbf"

FSO = CreateObject('Scripting.FileSystemObject')
FSO.MoveFile(mcOriginal,mcNewCase)
RELEASE fso

The mcOriginal filename was created by VFP and ended up being all lowercase.
After executing the above Windows Script, the file name case was changed as desired.

PS: mgagnon might want to add this small utility to his excellent Windows Scripting FAQ in this forum.

JRB-Bldr
 
Rick,
Has Anders Altberg been here in this forum as well?
-Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top