Convert long filenames to short.

Atomic Shrimp

Humanoid lifeform
Local time
Today, 05:12
Joined
Jun 16, 2000
Messages
1,954
Can anyone tell me a way of finding the short filename for a given long filename.
 
Mike, I know you are good with string manipulation. can't you loop back through the longfilename string and look for "/" then use that in a mid function to return the short filename as an extract of the long...

Something like:

Dim longFile as string
Dim shortFile as string
Dim I as integer

'I'm not very good at string manipulation as you can see

For I = Len(longFile) to 1 step -1
If Mid(longFile,I,1) = "/" then
'only assign if not already
If shortFile <>"" then
shortFile = Mid(longFile,I,5000)
End if
End if
Next I

shortFile will then hold all characters after the last slash in the longFile variable.

Ian
 
Thanks Ian, but slight misunderstanding I think, probably my fault for not giving an example.

I need to get the DOS filename ("Myfile~1.txt") for a given long file name ("My file with a long name.txt")

Unfortunately it can't be directly derived from the long file name alone, because if you have two similarly named files, Windows will name one of them "Myfile~2.txt", usually this is the more recently created of the two, but I don't think that's a rock-solid rule.
 
Hi Mike,

i came across this but haven't used it at all so can't tell you if it works or not

best wishes

anke
 

Users who are viewing this thread

Back
Top Bottom