This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Obtaining short DOS file names?


Ok, this version works. It's faster than my script, but my version shortens
the entire full file name. 

> -----Original Message-----
> From: Barry Buchbinder [mailto:BBUCHBINDER@niaid.nih.gov]
> Sent: Tuesday, June 06, 2000 3:40 PM
> To: 'cygwin@sourceware.cygnus.com'
> Subject: RE: Obtaining short DOS file names?
> 
> 
> 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@niaid.nih.gov]
> > Sent: Tuesday, June 06, 2000 12:43 PM
> > To: 'cygwin@sourceware.cygnus.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@CS.Cornell.EDU]
> > > Sent: Wednesday, May 31, 2000 10:38 AM
> > > To: 'cygwin@sourceware.cygnus.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@sourceware.cygnus.com
> 

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]