delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/12/20/19:50:54

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_THEBAT,KHOP_THREADED,MIME_BASE64_BLANKS,SPF_SOFTFAIL,TW_RG
X-Spam-Check-By: sourceware.org
Date: Fri, 21 Dec 2012 04:35:32 +0400
From: Andrey Repin <anrdaemon AT freemail DOT ru>
Reply-To: Andrey Repin <cygwin AT cygwin DOT com>
Message-ID: <99995944.20121221043532@mtu-net.ru>
To: Denis Excoffier <cygwin AT Denis-Excoffier DOT org>, cygwin AT cygwin DOT com
Subject: Re: argv @-expansion with pathname containing spaces
In-Reply-To: <DB2D51D9-47EB-4609-A28E-9FF0FA1E5472@Denis-Excoffier.org>
References: <20121219162048 DOT GA4564 AT qp9482> <CAEhDDbDcoiKng6D2zqb-_xKrMUnt_H8Lj7FNPgXnMfis0R9mpw AT mail DOT gmail DOT com> <20121220115536 DOT GA300 AT qp9482> <CA+sc5mmhQiSseK3279nSW-0xwyODzMUYEY13pb_CJpwD6QTmng AT mail DOT gmail DOT com> <DB2D51D9-47EB-4609-A28E-9FF0FA1E5472 AT Denis-Excoffier DOT org>
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id qBL0ootL026526

Greetings, Denis Excoffier!

>> On Thu, Dec 20, 2012 at 6:55 AM, Denis Excoffier wrote:
>>> However i don't see how to
>>> derive the 8.3 form from my original filename, using DOS only.
>> 
>> The /X argument to cmd.exe's dir command will give you the 8.3 name if
>> it exists.  Note that your system can be configured to not produce the
>> 8.3 form.

> I tried 'dir /X %pathname%', or 'dir /X /B %pathname%' (and other combinations),
> i can produce "some" 8.3 strings, bug was unable to produce the replacement
> of the full path (with 8.3 strings replaced everywhere). And setting the
> result in another variable seems another challenge…

> On the other hand, i have discovered something funny to calculate the directory
> where a bat file is installed:

> pushd %0\..
> set dirname=%cd%
> popd

set dirname="%~dp0"

Read through SET /?, there's some marvel to be found.

> This seems to work in all situations (spaces in filenames, bat file called through
> absolute path or relative path, even the simple foo.bat works…). It also removes
> the annoying quotes that are set around %0.

> It's a good trick, did anybody know this?

No need for tricks. The value you're seeking is readily available.


--
WBR,
Andrey Repin (anrdaemon AT freemail DOT ru) 21.12.2012, <04:34>

Sorry for my terrible english...

- Raw text -


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