How do I convert long to short pathnames?
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Denis_Ballant
Posted On:   Friday, February 22, 2002 01:58 PM

How do I get the short pathnames (8.3) on a Windows system?

Re: How do I convert long to short pathnames?

Posted By:   Anonymous  
Posted On:   Tuesday, March 29, 2011 03:10 PM

1. start -> run: cmd
2. go to desired folder, i.e.
cd "C:Documents and SettingsAll UsersStart MenuApplications"
3. type
command.com

you'll get command prompt like
C:DOCUME~1ALLUSE~1STARTM~1APPLIC~1>

Re: How do I convert long to short pathnames?

Posted By:   Andrey_Karachoun  
Posted On:   Monday, November 25, 2002 04:11 AM

I think the best way is to write your own piece of code that converts long pathnames to short ones, taking first 6 characters of each file/folder of the path and adding "~1" to them.

To do this, it is better for you to create first a java.util.StringTokenizer from your pathname String and then write smth like this:


String shortpath = "";
StringTokenizer tokenizer = new StringTokenizer(longpath, "\");
while(tokenizer.hasMoreTokens() == true)
{
String temp = tokenizer.nextToken();
if(temp.length() >= 8)
temp = temp.substring(0, 6) + "~1";
shortpath += temp + "\";
}

Re: How do I convert long to short pathnames?

Posted By:   AlessandroA_Garbagnati  
Posted On:   Tuesday, March 12, 2002 09:16 AM

Denis,

I'm afraid that the best solution is write a native interface to talk with the operating system, since that is something that is very WinOS dependant.

Re: How do I convert long to short pathnames?

Posted By:   Heinrich_Soebke  
Posted On:   Monday, March 4, 2002 01:18 AM

not really a solution, but the brute force attack:
use Runtime.exec() and parse the output.

On Windows NT there's an option of the dir command (/X), which shows the short names.
About | Sitemap | Contact