long-to-short dir/filenames 
Author Message
 long-to-short dir/filenames


filenames for input

the problem is that I have this filelist.txt  with LONG dir/filenames,
like:

c:\mydirectorya\subdirectorya\longfilename.txt
c:\mydirectoryb\subdirectoryb\longfilenameb.txt
c:\foobar\onetwothree.txt


c:\MYDIRE~1\SUBDIR~1\LONGFI~1.TXT
c:\MYDIRE~2\SUBDIR~2\LONGFI~1.TXT
c:\FOOBAR\ONETWO~1.TXT

I think the only correct way to do this  is to execute and analyze a system
DIR  for each row..
using  AWK, SED, or PERL  and eventually a BAT file for speed (i.e. instead
of calling many times the "system" command in AWK)
anyone knows how to do it?

I'm on Windows 2000,
w2k has   DIR /X for displaying SFN
w98 display SFN with a normal DIR
but both seems to not display the dir shortnames (perhaps you can see them
by executing a DIR for each dir/subdir in the row.. but I think it's a bad
method)



Sat, 08 Feb 2003 03:00:00 GMT  
 long-to-short dir/filenames
[followups limited to comp.lang.perl.misc]


: filenames for input
:
: the problem is that I have this filelist.txt  with LONG dir/filenames,
: like:
:
: c:\mydirectorya\subdirectorya\longfilename.txt
: c:\mydirectoryb\subdirectoryb\longfilenameb.txt
: c:\foobar\onetwothree.txt
:
:

:
: c:\MYDIRE~1\SUBDIR~1\LONGFI~1.TXT
: c:\MYDIRE~2\SUBDIR~2\LONGFI~1.TXT
: c:\FOOBAR\ONETWO~1.TXT

[snip]

: I'm on Windows 2000,

Very easy in Perl [UNTESTED CODE]:

#!perl -wi.bak
use strict;
use Win32;
while (<>) {
  chomp;
  print Win32::GetShortPathName($_),"\n";

Quote:
}



Sat, 08 Feb 2003 03:00:00 GMT  
 long-to-short dir/filenames
great!! this Perl script works and it's TENS times more fast than the AWK
not-native solution!
Quote:
> use strict;
> use Win32;
> while (<>) {
>   chomp;
>   print Win32::GetShortPathName($_),"\n";
> }



Sun, 09 Feb 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to read directories into TTreeView

2. long-to-short dir/filenames

3. long versus short filenames in win32

4. Getting long filename from 8.3 filename?

5. How to glob using short filenames under Win32?

6. What kinds of .OBJ files are there?

7. SQL Workstation/Delphi connectivity

8. Date handling between Delphi 1.0 and Access 2.0

9. Match longest or shortest substring?

10. short / long names on Win NT

11. No idea about perl, Long post, short question

12. Help unpacking Little-Endian shorts and longs

 

 
Powered by phpBB® Forum Software