Convert long filenames to 8.3 format?

T

Terry Pinnell

Although probably not directly on-topic, I'm hoping the experts here
can help please. How I can automatically convert a long filename like
C:\Program Files\This example.exe to a DOS 8.3 name like
C:\Progra~1\Thisex~1.exe ?

I'm sure I've seen some clever way to do it from an XP Explorer or My
Computer folder, but I'm darned if I can find it. I recall something
like dragging the file into a Command Prompt window, but when I try
that it merely displays the original long name.

The reason I want to do this is to place 'shortcuts' in text files. My
text editor, TextPad, lets me r-click strings like the following to go
directly to the targets:

http://www.example.com to go to a website

file://D:/Docs/Example.txt to open that file on my HD

file://D:/Docs/Thisex~1.txt to open the file 'D:\Docs\This
Example.txt' on my HD

So, taking that last example, I want to be able to select the file
D:\Docs\This Example.txt in say an XP folder, and get
D:\Docs\Thisex~1.txt onto the clipboard, without having to do it
manually. Rather like the indispensable MS Powertoys TweakUI facility
'Send to > Clipboard as a name'.
 
P

Pegasus \(MVP\)

Terry Pinnell said:
Although probably not directly on-topic, I'm hoping the experts here
can help please. How I can automatically convert a long filename like
C:\Program Files\This example.exe to a DOS 8.3 name like
C:\Progra~1\Thisex~1.exe ?

I'm sure I've seen some clever way to do it from an XP Explorer or My
Computer folder, but I'm darned if I can find it. I recall something
like dragging the file into a Command Prompt window, but when I try
that it merely displays the original long name.

The reason I want to do this is to place 'shortcuts' in text files. My
text editor, TextPad, lets me r-click strings like the following to go
directly to the targets:

http://www.example.com to go to a website

file://D:/Docs/Example.txt to open that file on my HD

file://D:/Docs/Thisex~1.txt to open the file 'D:\Docs\This
Example.txt' on my HD

So, taking that last example, I want to be able to select the file
D:\Docs\This Example.txt in say an XP folder, and get
D:\Docs\Thisex~1.txt onto the clipboard, without having to do it
manually. Rather like the indispensable MS Powertoys TweakUI facility
'Send to > Clipboard as a name'.

I don't think you can do this, simply because the conversion from
LFNs to SFNs does not result in a predetermined SFN. The final
name depends on what's already in the current folder. You can see
this for yourself by creating two files:
a) "This Example.txt"
b) "This Ex.txt"

The SFN will be depend on which file you create first.

Create "This Example.txt" first:
08/04/2007 21:30 3 THISEX~1.TXT This Example.txt
08/04/2007 21:31 3 THISEX~2.TXT This Ex.txt

Create "This Ex.txt" first:
08/04/2007 21:32 3 THISEX~1.TXT This Ex.txt
08/04/2007 21:32 3 THISEX~2.TXT This Example.txt

Any tool that can do this must read the access the LFN on the
disk and check the corresponding SFN.
 
A

Alan Edwards

I am sure I have come across what you want but cannot find it.
The closest I have is a VBS script from Bill James (7 years old for
Win98) called FileFldrInfo.vbs
It does not appear on Bill's page at http://www.billsway.com/vbspage/
so you may try getting in touch with him.
The info in the file:

'FileFldrInfo.vbs - Create right click context menu and
'SendTo shortcut to get file and folder information.
'Options for DOS 8.3 path or name or long path or name.
'Requires Windows 98 or Internet Explorer 5.01 +.
'To install, double click this file.
'© Bill James - - rev 30 Jan 2000

....Alan
 
P

Poprivet

Terry said:
Although probably not directly on-topic, I'm hoping the experts here
can help please. How I can automatically convert a long filename like
C:\Program Files\This example.exe to a DOS 8.3 name like
C:\Progra~1\Thisex~1.exe ?

I'm sure I've seen some clever way to do it from an XP Explorer or My
Computer folder, but I'm darned if I can find it. I recall something
like dragging the file into a Command Prompt window, but when I try
that it merely displays the original long name.

The reason I want to do this is to place 'shortcuts' in text files. My
text editor, TextPad, lets me r-click strings like the following to go
directly to the targets:

http://www.example.com to go to a website

file://D:/Docs/Example.txt to open that file on my HD

file://D:/Docs/Thisex~1.txt to open the file 'D:\Docs\This
Example.txt' on my HD

So, taking that last example, I want to be able to select the file
D:\Docs\This Example.txt in say an XP folder, and get
D:\Docs\Thisex~1.txt onto the clipboard, without having to do it
manually. Rather like the indispensable MS Powertoys TweakUI facility
'Send to > Clipboard as a name'.

I don't understand what you're trying to do, but any app that requires SFN
will have t hem created them on its own; you shouldn't have to mess with
them at all.
XP is unlike 98 et al in that it doesn't use the SFNs underneath the LFNs
so it's not, AFAIK, possible or at least not easy to do.
 
W

Wesley Vogel

dir /x
Displays the short names generated for files on NTFS and FAT volumes. The
display is the same as the display for /n, but short names are displayed
after the long name.


--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
 
B

Bill James

There is a script on my web site to do this, but it will take a little manual configuration to implement. Go to http://billsway.com/notes_public/ and download "Clipboard as 8.3 Path.vbs". Save that someplace on the hard drive where you won't accidentally delete it, then add a shortcut in the SendTo folder (C:\Documents and Settings\[username]\SendTo).

The script uses the "InternetExplorer.Application" object, but the IE Security settings may not allow the script access to the clipboard with current settings. The only way to solve that is to modify your IE Security settings, but if you are careful about how you do that the risk is minimal. Open IE, Tools, Internet Options, then on the Security tab select Trusted sites, the Sites button, and add "about:clipcopy" to the sites list. You may also have to adjust the security settings for Trusted Zone to allow clipboard access. Understand that doing so allows any site in the Trusted sites list to access the clipboard, but you really shouldn't be adding any site there that you can't, well, Trust.

With that all done, you can select a file or folder in Windows Explorer, right click, select Send To, then the new item "Clipboard as 8.3 Path". Multiple files and/or folders are allowed, but if you select too many long paths you will get an error for maximum length exceeded.
 
C

cquirke (MVP Windows shell/user)

On Sun, 08 Apr 2007 11:50:17 +0100, Terry Pinnell
Although probably not directly on-topic, I'm hoping the experts here
can help please. How I can automatically convert a long filename like
C:\Program Files\This example.exe to a DOS 8.3 name like
C:\Progra~1\Thisex~1.exe ?

Dir /X will show the actual short names, whereas what you see with the
%~s1 logic may be spurious (as that works even if the file or path
doesn't exist).

Let's test that... hmm, seems as if the logic is:
- if exists, show the 8.3 name
- if does not exist, show the given name

That's better than generating faux short names, and is OK if you
combine it with If Exist logic, or other "existance" tests.
I'm sure I've seen some clever way to do it from an XP Explorer or My
Computer folder, but I'm darned if I can find it.

In Win95/98, Properties would show you the real 8.3 name of a file,
but this was stripped out in WinME. Silly, as there are times when
you DO have to pay attention to the man behind the curtain.
I recall something like dragging the file into a Command Prompt
window, but when I try that it merely displays the original long name.

Command.com is LFN-aware, but the behavior can change if it dips into
a LFN-unaware context. You can test this yourself; start a Cmd or
Command prompt in (say) "C:\Program Files" and do a few things; at
some point, the command prompt will switch to C:\PROGRA~1 and once it
does, it generally won't switch back for the rest of that session.
The reason I want to do this is to place 'shortcuts' in text files. My
text editor, TextPad, lets me r-click strings like the following to go
directly to the targets:

http://www.example.com to go to a website

file://D:/Docs/Example.txt to open that file on my HD

file://D:/Docs/Thisex~1.txt to open the file 'D:\Docs\This
Example.txt' on my HD

So, taking that last example, I want to be able to select the file
D:\Docs\This Example.txt in say an XP folder, and get
D:\Docs\Thisex~1.txt onto the clipboard, without having to do it
manually. Rather like the indispensable MS Powertoys TweakUI facility
'Send to > Clipboard as a name'.

Does it help to "use quotes for names with spaces"?


-------------------- ----- ---- --- -- - - - -
Tip Of The Day:
To disable the 'Tip of the Day' feature...
 
C

cquirke (MVP Windows shell/user)

On Sun, 8 Apr 2007 11:10:59 -0400, "Poprivet"
XP is unlike 98 et al in that it doesn't use the SFNs underneath the LFNs
so it's not, AFAIK, possible or at least not easy to do.

That's not true, if file system is FATxx.

On NTFS, AFAIK there are still 8.3 names stored, unless you explicitly
disable that; if you do, then certain things can break.

NT OSs such as XP differ in how 8.3 indexes are incrimented after the
"first few" cases. Whereas Win9x will go BLAHBL~1, BLAHBL~2,
BLAHBL~3, .. BLAHB~87 etc., at some point an NT-based OS will switch
to a hexadecimal "8" stub for the name.

This, and other LFN issues, can bedevil attempts to predict what will
happen and accurately find files via 8.3 names etc.
 
T

Terry Pinnell

Bill James said:
There is a script on my web site to do this, but it will take a little manual configuration to implement. Go to http://billsway.com/notes_public/ and download "Clipboard as 8.3 Path.vbs". Save that someplace on the hard drive where you won't accidentally delete it, then add a shortcut in the SendTo folder (C:\Documents and Settings\[username]\SendTo).

The script uses the "InternetExplorer.Application" object, but the IE Security settings may not allow the script access to the clipboard with current settings. The only way to solve that is to modify your IE Security settings, but if you are careful about how you do that the risk is minimal. Open IE, Tools, Internet Options, then on the Security tab select Trusted sites, the Sites button, and add "about:clipcopy" to the sites list. You may also have to adjust the security settings for Trusted Zone to allow clipboard access. Understand that doing so allows any site in the Trusted sites list to access the clipboard, but you really shouldn't be adding any site there that you can't, well, Trust.

With that all done, you can select a file or folder in Windows Explorer, right click, select Send To, then the new item "Clipboard as 8.3 Path". Multiple files and/or folders are allowed, but if you select too many long paths you will get an error for maximum length exceeded.

Many thanks to all for those helpful replies. The simple Dir /x
approach is almost enough in itself, but that 'Send To...' tool is
just the job - excellent!

The method of adding %20 would indeed seem to be a promising solution,
but unfortunately it doesn't work! I had previously been in touch with
TextPad's author, who said:

---------
"According to RFC1738 (http://www.faqs.org/rfcs/rfc1738.html), spaces
are not valid in URLs and have to be represented by their 2-digit hex
character code, preceded by "%". Hence, using your example, you must
type:
file://D:/Program%20Files/
Unfortunately, Microsoft are too clever by half when interpreting
URLs, so this doesn't work either! The problem is, instead of passing
it straight on to a web browser, which understands URLs, the shell
parses strings starting with "file://", to determine which application
should display the folder or file. This is actually what you want,
but unfortunately the parser does not interpret the hex codes, so
cannot find the file or folder and rejects the request."
 
T

Terry Pinnell

Terry Pinnell said:
Bill James said:
There is a script on my web site to do this, but it will take a little manual configuration to implement. Go to http://billsway.com/notes_public/ and download "Clipboard as 8.3 Path.vbs". Save that someplace on the hard drive where you won't accidentally delete it, then add a shortcut in the SendTo folder (C:\Documents and Settings\[username]\SendTo).

The script uses the "InternetExplorer.Application" object, but the IE Security settings may not allow the script access to the clipboard with current settings. The only way to solve that is to modify your IE Security settings, but if you are careful about how you do that the risk is minimal. Open IE, Tools, Internet Options, then on the Security tab select Trusted sites, the Sites button, and add "about:clipcopy" to the sites list. You may also have to adjust the security settings for Trusted Zone to allow clipboard access. Understand that doing so allows any site in the Trusted sites list to access the clipboard, but you really shouldn't be adding any site there that you can't, well, Trust.

With that all done, you can select a file or folder in Windows Explorer, right click, select Send To, then the new item "Clipboard as 8.3 Path". Multiple files and/or folders are allowed, but if you select too many long paths you will get an error for maximum length exceeded.

Many thanks to all for those helpful replies. The simple Dir /x
approach is almost enough in itself, but that 'Send To...' tool is
just the job - excellent!

The method of adding %20 would indeed seem to be a promising solution,
but unfortunately it doesn't work! I had previously been in touch with
TextPad's author, who said:

---------
"According to RFC1738 (http://www.faqs.org/rfcs/rfc1738.html), spaces
are not valid in URLs and have to be represented by their 2-digit hex
character code, preceded by "%". Hence, using your example, you must
type:
file://D:/Program%20Files/
Unfortunately, Microsoft are too clever by half when interpreting
URLs, so this doesn't work either! The problem is, instead of passing
it straight on to a web browser, which understands URLs, the shell
parses strings starting with "file://", to determine which application
should display the folder or file. This is actually what you want,
but unfortunately the parser does not interpret the hex codes, so
cannot find the file or folder and rejects the request."
---------

I subsequently had an even neater solution from Michael Bednarek in
another group. Unknown to me for all the years that I've used
Powertoys TweakUI, if you press the Ctrl key while selecting 'Send To
Clipboard as Name', it will place the file's *short* name onto the
clipboard. Exactly what I need!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top