delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/06/06/15:50:10

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-ID: <DC328EEA2ED4D211B35700105A9CB3B90C8D30@flash.niaid.nih.gov>
From: Barry Buchbinder <BBUCHBINDER AT niaid DOT nih DOT gov>
To: "'cygwin AT sourceware DOT cygnus DOT com'" <cygwin AT sourceware DOT cygnus DOT com>
Subject: RE: Obtaining short DOS file names?
Date: Tue, 6 Jun 2000 15:40:07 -0400
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)

The output of dir is different in command.com and cmd.exe.  In a version I
have of cmd.exe compiled for win9x, the following works for me.

function sfn() {
  win95cmd /c dir /x "$1" | \
    sed -e '/^ /d' \
      -e 's/^......................................//' \
      -e 's/^ *//' -e 's/ .*//'
  }

You might have to play with the options to dir and with the sed processing
to get it to work for Win2k.

- Barry

 -----Original Message-----

     To: "'cygwin at sourceware dot cygnus dot com'" <cygwin at sourceware
dot cygnus dot com> 
     Subject: RE: Obtaining short DOS file names? 
     From: Paul Stodghill <stodghil at cs dot cornell dot edu> 
     Date: Tue, 6 Jun 2000 13:19:38 -0400 

This doesn't work under Win2k. First, it doesn't like "command.com". After
changing that to "cmd", it just prints the date when the first was
modified... 

> -----Original Message-----
> From: Barry Buchbinder [mailto:BBUCHBINDER AT niaid DOT nih DOT gov]
> Sent: Tuesday, June 06, 2000 12:43 PM
> To: 'cygwin AT sourceware DOT cygnus DOT com'
> Subject: RE: Obtaining short DOS file names?
> 
> 
> This works on Win98.
> 
> Try putting this function in .bashrc
> 
> function sfn() {
>       command.com /c dir "$1" | sed -e '/^ /d' -e 
> 's/^............/&^G/'
> -e 's/^G.*$//' -e 's/ *$//' -e 's/  */\./'
>       }
> 
> (Note: "^G" is a control-G/bell, which I don't expect to find in a DOS
> filename.)
> 
> Then if you just want a list, you can do the following
>       $ sfn dos_file_spec
> If you want to feed the list to a program, do
>       $ prog `sfn dos_file_spec`
> Remember to quote or escape anything that bash might expand.
> 
> Command.com must have the ".com" typed.  I'm not sure that it 
> will work or
> can be easily adapted for cmd.exe.  sfn takes a single argument.
> 
> It's ugly and slow, but it works for me.  Excuse me if my sed 
> programming
> was less than elegant.
> 
> - Barry Buchbinder
> 
>  -----Original Message-----
> 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019