PDA

View Full Version : Solved: How Write Path for DOS Command



Cyberdude
05-23-2005, 01:17 PM
I have a .BAT file that I use to clear a Netscape cache that is located at
C:\NetCache\Cache It works. Note that none of the names in the path exceed 8 characters.
Now I have another similar .BAT file for clearing out the FoxFire cache, except the path has names with more than 8 characters:
C:\Documents and Settings\Sid Bordelon.SID\Application Data\Mozilla\Firefox\Profiles\a1ao70jc.default\Cache\*.* My guesses about how to write the longer-than-8-chars names must be failing, because the .BAT file isn't clearing the cache. My most recent attempt at substitution is:
C:\Docume~1\Sid Bor~1~SID\Applic~1\Mozilla\Firefox\Profiles\a1ao70jc~default\Cache\*.* Can anyone tell me how to change the names into 8-character equivalents? :banghead:

mvidas
05-23-2005, 01:58 PM
Good luck!!
Somewhat kidding aside, you have the beginning of the right idea, but its a little stranger than that.

If either portion of the 8.3 filename is longer than 8 or 3 (or they contain a space), you're gonna get a tilda and a number.
Using your example of the folder name "Sid Bordelon.SID", the "Sid Bordelon" is longer than 8 characters and contains a space. Chances are your short filename is going to be "SidBor~1.SID", as it always keeps the first 3 letters of the extension (even for a folder like this). If you had a folder named C:\Sid.Bordelon\, that would instead be "sid~1.bor"
It increments the number after the tilda if you have more than one file/folder with the same initial lettering. Easy, huh? There are 10000000 other rules for it too, which is why I try not to use them now!
2 things you could do, in order of my (and mine only) suggested preference:
1) Convert the .bat to a .vbs file. .vbs files are a lot better than .bat's, though it might take a bit of time converting them and getting used the exact syntax. worth the trouble, in my opinion
2) You could use the following function to get them one at a time:Function ReturnShortName(ByVal LongName As String, Optional ByVal bFolder As Boolean, _
Optional ByVal bFile As Boolean) As String
Dim fso As Object, fl As Object
Set fso = CreateObject("scripting.filesystemobject")
If bFolder Then
Set fl = fso.GetFolder(LongName)
ReturnShortName = fl.ShortPath
ElseIf bFile Then
Set fl = fso.GetFile(LongName)
ReturnShortName = fl.ShortPath & "\" & fl.ShortName
End If
Set fso = Nothing
Set fl = Nothing
End Function Set bFolder = True if it is a folder you're looking for, and bFile = True if it is a filename you want. Just put Debug.Print ReturnShortName("C:\Documents and Settings\Sid Bordelon.SID\Application Data\Mozilla\Firefox\Profiles\a1ao70jc.default\Cache\", bFolder:=True)in a sub, and similar lines as well, to get what you need!
Matt

Cyberdude
05-24-2005, 04:18 PM
Thanks for poiinting me in the right sirection, Matt. I'll play with it some more. :beerchug:

mark007
05-28-2005, 03:03 AM
Just put quotes round the filename in the batch file and all will work fine.

:)

Cyberdude
05-28-2005, 10:46 AM
Hey, Mark, thanx for the great advice. After months of trying I finally got it to work. :friends: