Mail Archives: cygwin/2000/06/06/10:46:31
------_=_NextPart_000_01BFCFC5.E1958926
Content-Type: text/plain;
charset="iso-8859-1"
I've attached a Perl script that converts long file names to short file
names. Hope that some else finds this useful.
milhouse% perl shorten.pl '/cygdrive/c/Program Files/Microsoft Visual \
Studio/VIntDev98/ScriptLibrary/RECORDSET.HTM'
/cygdrive/c/PROGRA~1/MICROS~4/VINTDE~1/SCRIPT~1/RECORD~1.HTM
milhouse%
> -----Original Message-----
> From: Paul Stodghill [mailto:stodghil AT CS DOT Cornell DOT EDU]
> Sent: Wednesday, May 31, 2000 10:38 AM
> To: 'cygwin AT sourceware DOT cygnus DOT com'
> Subject: RE: Obtaining short DOS file names?
>
>
> Chris wrote,
> > There is no cygwin-specific way of getting the short file
> > name. The concept
> > has no meaning on UNIX. There are Windows programs available
> > which do this.
> > 'dir' is one of them, for instance.
>
> Gotcha. I can hack something up from this.
>
> > Is there some reason why quoting the filename doesn't work?
>
> It would, but it will take me a while to track down all of
> the places that
> the scripts are broken. I'm looking for something quick and
> dirty to get
> going.
>
> Thanks.
>
> --
> Want to unsubscribe from this list?
> Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
>
------_=_NextPart_000_01BFCFC5.E1958926
Content-Type: application/octet-stream;
name="shorten.pl"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="shorten.pl"
# -*- perl -*-=0A=
=0A=
eval 'exec perl -S $0 ${1+"$@"}'=0A=
if $running_under_some_shell;=0A=
=0A=
$FILE =3D $ARGV[0];=0A=
if ( "$FILE" eq "" ) {=0A=
print "Usage: ntutils/shorten filename" > STDERR;=0A=
exit 1=0A=
}=0A=
$FILE =3D `cygpath -w "$FILE"`;=0A=
chomp $FILE;=0A=
$FILE =3D~ s|\\|/|g;=0A=
=0A=
@STACK =3D reverse(split(/\//,$FILE));=0A=
=0A=
$NEWNAME =3D pop @STACK;=0A=
=0A=
while ( $#STACK >=3D 0 ) {=0A=
$OLD_FILE =3D pop @STACK;=0A=
$NEWNAME2 =3D $NEWNAME;=0A=
$NEWNAME2 =3D~ s|/|\\|g;=0A=
$NEW_FILE =3D `cmd /c \"dir /x \\\"$NEWNAME2\\\"\\\\\" | egrep =
\"$OLD_FILE\"\'$\' | cut -c40-51`;=0A=
chomp $NEW_FILE;=0A=
$NEW_FILE =3D~ s/ +$//;=0A=
if ( $NEW_FILE eq "" ) { =0A=
$NEW_FILE =3D $OLD_FILE; =0A=
}=0A=
$NEWNAME =3D $NEWNAME . "/" . $NEW_FILE;=0A=
}=0A=
=0A=
print `cygpath -u "$NEWNAME"`;=0A=
------_=_NextPart_000_01BFCFC5.E1958926
Content-Type: text/plain; charset=us-ascii
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
------_=_NextPart_000_01BFCFC5.E1958926--
- Raw text -