This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: argv @-expansion with pathname containing spaces
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@freemail.ru) 21.12.2012, <04:34>
Sorry for my terrible english...