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

fileexists method

Status
Not open for further replies.

gaburnboy

IS-IT--Management
Jul 10, 2010
2
US
fileexists returns false when filename provided to method has 2 or more consecutive spaces in the filename. any work around?
code works when passed "normal" filename, but if the filename has consecutive spaces in it, fielexist returns false -
example -
"Diaz - 04.10.10 legal briefing" if fileexist on this filename, returns false, if take out 1 of spaces between leagl & briefing, fileexist returns true. cant find anything on web regarding known problem, dont really want to change all the filenames i need to process (someone elses data), so wondering if other options?
 
>but if the filename has consecutive spaces in it, fielexist returns false
It should not be the issue. If you can get the file (getfile() method) then echo the filename with escape function, see what you get for investigation.
[tt] wscript.echo escape(filename)[/tt]
If you cannot even get the file with getfile(), that may be another story.
 
"Diaz - 04.10.10 legal briefing"
I reckon the dots in the file name are more problematic.
Bad practice.

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Liberal use of dot in the file name is not problematic per se. In some areas of computing, it is a bit of idiosyncrasy. Looking from the outside of those areas, it takes, indeed, a bit of mental adjustment to accept it open-arm. But it is not a problem per se, I would say.
 
>fileexists returns false when filename provided to method has 2 or more consecutive spaces in the filename

As tsuji has hinted, this is more likely to be because what you think is a space ... isn't. Or, more accurately, isn't an ANSI character 32

>Bad practice

Nothing wrong with using multiple periods in Windows long filenames.
 
ok. you've pointed me in the right direction.
its not fileexists, but some unseen chars in the filename that appear as spaces.
if i blank out the 2 consecutive spaces in the filename, and replace them with spaces, then fileexists returns true.

is there vbscript code snippet to xlate the characters of a string into ascii or hex so i can determine what these "hidden" chars are?
im thinking of array & looking at each char with asc function, but checking first.
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top