Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

short filenames show up when I don't want them to

12 views
Skip to first unread message

cumin

unread,
Feb 6, 2007, 8:22:19 AM2/6/07
to
I'm not sure if this is the right place for my question; if not please
point me appropriately

When I run gnu awk on win2000 or xp, the filenames in my path are
shortened, which is maddening. Can this be prevented? Oddly, it does
not occur with my sed.

F:\mathtext_comp_db\text_proc>gawk --v
GNU Awk '3.1.4' (DJGPP port 2005-03-20 (r1))
Copyright (C) 1989, 1991-2003 Free Software Foundation.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.

F:\MATHTE~1\TEXT_P~1>

***************************************************************

F:\mathtext_comp_db\text_proc>sed --v
super-sed version 3.62
based on GNU sed version 4.1

Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There
is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE,
to the extent permitted by law.

F:\mathtext_comp_db\text_proc>

Timo Salmi

unread,
Feb 6, 2007, 9:02:09 AM2/6/07
to
cumin <> wrote:
> When I run gnu awk on win2000 or xp, the filenames in my path are
> shortened, which is maddening. Can this be prevented?

I do not know. But it is possible to find out the long format of a short
name, if that is of any help to you.

138} How can I get the long name of a short-named file or folder?
182662 Jan 13 2007 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html

Ted Davis

unread,
Feb 6, 2007, 9:08:36 AM2/6/07
to
On 6 Feb 2007 05:22:19 -0800, "cumin" <jkilb...@gmail.com> wrote:

>I'm not sure if this is the right place for my question; if not please
>point me appropriately
>
>When I run gnu awk on win2000 or xp, the filenames in my path are
>shortened, which is maddening. Can this be prevented? Oddly, it does
>not occur with my sed.

You told us nothing we don't already know about gawk, or don't need to
know, but nothing of the actual nature of the problem. Even what you
did say is confusing (there are no filenemes in the Path environment
variable).

comp.lang.awk might be a better place to ask, but they are mostly *ix
oriented.

Show me some code - the minimum example that shows the problem.
I use gawk frequently and have never encountered anything that could
be described the way you described that.

--
T.E.D. (tda...@gearbox.maem.umr.edu)
Remove "gearbox.maem." from address - that one is dead

Matthias Tacke

unread,
Feb 6, 2007, 9:50:39 AM2/6/07
to
cumin schrieb:

> I'm not sure if this is the right place for my question; if not please
> point me appropriately
>
> When I run gnu awk on win2000 or xp, the filenames in my path are
> shortened, which is maddening. Can this be prevented? Oddly, it does
> not occur with my sed.
>
> F:\mathtext_comp_db\text_proc>gawk --v
> GNU Awk '3.1.4' (DJGPP port 2005-03-20 (r1))
> Copyright (C) 1989, 1991-2003 Free Software Foundation.
>

I think the problem is using a DJGPP port instead of, i.e
this one which I use without problems:

C:\test
15:44:58>gawk --v
GNU Awk 3.1.0
Copyright (C) 1989, 1991-2001 Free Software Foundation.

You may download a more recent version 3.1.3 from here:
http://gnuwin32.sourceforge.net/downlinks/gawk.php

HTH
Matthias

cumin

unread,
Feb 6, 2007, 12:05:58 PM2/6/07
to

I downloaded gawk from the link you gave, and still got the same
results. In other words, the prompt showing my path
E:\workspace file-stick>
has had the filenames shortened to
E:\WORKSP~1>

I'm not sure what sort of code people need to see.

E:\workspace file-stick>gawk --v


GNU Awk '3.1.4' (DJGPP port 2005-03-20 (r1))
Copyright (C) 1989, 1991-2003 Free Software Foundation.

...
E:\WORKSP~1>

foxidrive

unread,
Feb 6, 2007, 11:50:14 AM2/6/07
to
On Tue, 06 Feb 2007 15:50:39 +0100, Matthias Tacke <Matt...@Tacke.de>
wrote:

>cumin schrieb:
>> I'm not sure if this is the right place for my question; if not please
>> point me appropriately
>>
>> When I run gnu awk on win2000 or xp, the filenames in my path are
>> shortened, which is maddening. Can this be prevented? Oddly, it does
>> not occur with my sed.
>>
>> F:\mathtext_comp_db\text_proc>gawk --v
>> GNU Awk '3.1.4' (DJGPP port 2005-03-20 (r1))
>> Copyright (C) 1989, 1991-2003 Free Software Foundation.
>>
>
>I think the problem is using a DJGPP port

Yes, it is running command.com that forces short names, as a past thread
found. Use a 32 bit version of awk.

cumin

unread,
Feb 6, 2007, 12:39:10 PM2/6/07
to
On Feb 6, 11:50 am, foxidrive <got...@woohoo.invalid> wrote:
> On Tue, 06 Feb 2007 15:50:39 +0100, Matthias Tacke <Matth...@Tacke.de>

Yes, that is it. Thank you:

E:\workspace file-stick\gawk-3.1.3-2-bin\bin>gawk --v
GNU Awk 3.1.3


Copyright (C) 1989, 1991-2003 Free Software Foundation.

...
E:\workspace file-stick\gawk-3.1.3-2-bin\bin>

Larry__Weiss

unread,
Feb 6, 2007, 3:11:46 PM2/6/07
to
cumin wrote:
> When I run gnu awk on win2000 or xp, the filenames in my path are
> shortened, which is maddening. Can this be prevented? Oddly, it does
> not occur with my sed.
>

I see that effect also when I run certain utilities
(%windir%\system32\edit.com, for example) from the command line.
I asked about it here about a year or so ago, and do not remember
getting an explanation that could remedy it (for example, run something
afterwards to restore the prompt to display long filenames.)

- Larry

Larry__Weiss

unread,
Feb 6, 2007, 3:18:07 PM2/6/07
to
%windir%\system32\mem.exe
also causes the expansion of $P in the PROMPT string to use
short file names.

I just played around with using
CD %CD%*
to reset to expanding $P to LFN's.

Seems to work.

- Larry

Larry__Weiss

unread,
Feb 6, 2007, 7:10:42 PM2/6/07
to
Larry__Weiss wrote:
> %windir%\system32\mem.exe
> also causes the expansion of $P in the PROMPT string to use
> short file names.
>
> I just played around with using
> CD %CD%*
> to reset to expanding $P to LFN's.
>
> Seems to work.
>

I spoke too soon. It turns out that you need to issue a
CD command with a * after each node in the directory path
to get back to the LFN prompt.

For example, for

C:\xyzzyxyzzy\xyzzyxyzzy

cd \XYZZYX~1*\XYZZYX~1*

Does anyone have a batch program that can insert the * chars
given %CD% ?

- Larry

foxidrive

unread,
Feb 6, 2007, 7:55:25 PM2/6/07
to

Try this Larry:

@echo off
set var=%cd%
set var=%var:\=*\%*
set var=%var::*=:%
echo CD "%var%"

Timo Salmi

unread,
Feb 7, 2007, 2:44:22 AM2/7/07
to
Larry__Weiss <l...@airmail.net> wrote:
> cumin wrote:
>> When I run gnu awk on win2000 or xp, the filenames in my path are
>> shortened, which is maddening.

> I see that effect also when I run certain utilities

> (%windir%\system32\edit.com, for example) from the command line. I
> asked about it here about a year or so ago, and do not remember
> getting an explanation that could remedy it (for example, run
> something afterwards to restore the prompt to display long
> filenames.)

To recount what I have presented earlier based on my FAQ (item 138). Try
e.g.
attrib C:\DOCUME~1
and you'll get
C:\Documents and Settings

This works one level at the time only, however, so one has to walk
through, which takes some doing. But the core of the method has existed
and been posted.

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland

Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip

Timo Salmi

unread,
Feb 7, 2007, 4:57:57 AM2/7/07
to
Larry__Weiss <l...@airmail.net> wrote:
> cumin wrote:
>> When I run gnu awk on win2000 or xp, the filenames in my path are
>> shortened, which is maddening.

> I see that effect also when I run certain utilities

> (%windir%\system32\edit.com, for example) from the command line.
> I asked about it here about a year or so ago, and do not remember
> getting an explanation that could remedy it (for example, run something
> afterwards to restore the prompt to display long filenames.)

@echo off & setlocal enableextensions enabledelayedexpansion
::
:: Display intermediate information for debugging or not
set debug=true
set debug=
::
:: Usage
if "%~1"=="" (
echo.
echo Usage: %~0 [FolderOrFileName]
goto :EOF
)
::
:: Give the name of the folder or the file
set name=%~f1
if not exist "%name%" (
echo "%name%" not found
goto :EOF)
::
:: Parse the path elements
set count_=0
set rest_=%name%
:_loop
for /f "tokens=1* delims=\" %%a in ("%rest_%") do (
set /a count_+=1
set var[!count_!]=%%a
set rest_=%%b
if defined rest_ goto _loop
)
::
:: Display the individual parts
if defined debug for /l %%i in (1,1,%count_%) do (
echo var[%%i]=!var[%%i]!)
if defined debug echo.
::
:: Build up the path
for /l %%i in (1,1,%count_%) do (
set longpath_=!longpath_!!var[%%i]!\
if %%i GTR 1 (
for /f "tokens=* delims=" %%f in (
'attrib "!longpath_:~0,-1!"') do (
set longpath_=%%f
set longpath_=!longpath_:~11!\
)
if defined debug echo !longpath_!
)
)
set longpath_=%longpath_:~0,-1%
::
:: Display the result
echo The given format was:
echo %name%
echo The long format is:
echo %longpath_%
::
endlocal & goto :EOF

Examples of the output
C:\_D\BAS>cmdfaq %temp%
The given format was:
C:\DOCUME~1\ts\LOCALS~1\Temp
The long format is:
C:\Documents and Settings\ts\Local Settings\Temp

C:\_D\BAS>cmdfaq %temp%\jupdate1.5.0.xml
The given format was:
C:\DOCUME~1\ts\LOCALS~1\Temp\jupdate1.5.0.xml
The long format is:
C:\Documents and Settings\ts\Local Settings\Temp\jupdate1.5.0.xml

C:\_D\BAS>cmdfaq C:\DOCUME~1\ts\LOCALS~1
The given format was:
C:\DOCUME~1\ts\LOCALS~1
The long format is:
C:\Documents and Settings\ts\Local Settings

C:\_D\BAS>cmdfaq TEST3~1.CMD
The given format was:
C:\_D\BAS\TEST3~1.CMD
The long format is:
C:\_D\BAS\TEST 3.CMD

Larry__Weiss

unread,
Feb 7, 2007, 11:39:13 AM2/7/07
to
foxidrive wrote:
>>Larry__Weiss wrote:
>>... It turns out that you need to issue a

>>CD command with a * after each node in the directory path
>>to get back to the LFN prompt.
>>For example, for
>> C:\xyzzyxyzzy\xyzzyxyzzy
>>cd \XYZZYX~1*\XYZZYX~1*
>>Does anyone have a batch program that can insert the * chars
>>given %CD% ?
>
> Try this Larry:
> @echo off
> set var=%cd%
> set var=%var:\=*\%*
> set var=%var::*=:%
> echo CD "%var%"
>

Works perfectly in my tests this morning.
And allowing the last line to actually do the CD will reset
the expansion of $P to the LFN variation.

Thanks!

- Larry

Timo Salmi

unread,
Feb 7, 2007, 12:48:51 PM2/7/07
to
foxidrive <got...@woohoo.invalid> wrote:
> @echo off
> set var=%cd%
> set var=%var:\=*\%*
> set var=%var::*=:%
> echo CD "%var%"

That is a nice, concise method. Have you checked that given the
wildcards it will always provide a unique solution?

Timo Salmi

unread,
Feb 7, 2007, 12:48:06 PM2/7/07
to foxidrive
foxidrive <got...@woohoo.invalid> wrote:
> @echo off
> set var=%cd%
> set var=%var:\=*\%*
> set var=%var::*=:%
> echo CD "%var%"

That is a nice, concise method. Have you checked that given the

Message has been deleted

Larry__Weiss

unread,
Feb 7, 2007, 1:38:05 PM2/7/07
to
Timo Salmi wrote:
> foxidrive <got...@woohoo.invalid> wrote:
>> @echo off
>> set var=%cd%
>> set var=%var:\=*\%*
>> set var=%var::*=:%
>> echo CD "%var%"
>
> That is a nice, concise method. Have you checked that given the
> wildcards it will always provide a unique solution?
>

That's a good question, and so far by the tests I've run on

@echo off %cdlfn.bat%


set var=%cd%
set var=%var:\=*\%*
set var=%var::*=:%
:: echo CD "%var%"

CD "%var%"

have resulted in the correct LFN named equivalent directory,
even when I introduce potential ambiguity into the match.

It seems that CD matches the smallest name it can when wildcards
are matched.

- Larry

foxidrive

unread,
Feb 7, 2007, 11:12:13 PM2/7/07
to

Looking at it again I notice that a folder like "a&bcd 123" will cause it
to fail due to the presence of the &, so the quoting below seems to fix
that.

@echo off
set "var=%cd%"
set "var=%var:\=*\%*"
set "var=%var::*=:%"

CD "%var%"


I tested the feature by opening cmd, loading command.com, then exiting to
cmd again where the path was displayed as a short pathname.

Does that work for you?

I tried it in a "Q:\a&bcd a123\" folder with no apparant result.

Larry__Weiss

unread,
Feb 8, 2007, 10:26:55 AM2/8/07
to
foxidrive wrote:
> Looking at it again I notice that a folder like "a&bcd 123" will cause it
> to fail due to the presence of the &, so the quoting below seems to fix
> that.
> @echo off
> set "var=%cd%"
> set "var=%var:\=*\%*"
> set "var=%var::*=:%"
> CD "%var%"
>
> I tested the feature by opening cmd, loading command.com, then exiting to
> cmd again where the path was displayed as a short pathname.
>
> Does that work for you?
>
> I tried it in a "Q:\a&bcd a123\" folder with no apparant result.
>

Yes, loading command.com and exiting causes $P to be expanded with short
file names.

I don't understand what you mean by


"I tried it in a "Q:\a&bcd a123\" folder with no apparant result."

- Larry


foxidrive

unread,
Feb 8, 2007, 6:34:12 PM2/8/07
to

My bad. I meant I tried the batch file above after doing the above and it
didn't restore the long path name.

Larry__Weiss

unread,
Feb 9, 2007, 7:12:57 AM2/9/07
to
foxidrive wrote:
>>foxidrive wrote:
>>> Looking at it again I notice that a folder like "a&bcd 123" will cause it
>>> to fail due to the presence of the &, so the quoting below seems to fix
>>> that.
>>> @echo off
>>> set "var=%cd%"
>>> set "var=%var:\=*\%*"
>>> set "var=%var::*=:%"
>>> CD "%var%"
>>>
>>> I tried it in a "Q:\a&bcd a123\" folder with no apparant result.
> ... I tried the batch file above after doing the above and it

> didn't restore the long path name.
>

I experimented with that exact name on a local and mapped drive, and
it worked for me. What type of drive is your Q: mapped to?

- Larry

foxidrive

unread,
Feb 9, 2007, 8:54:15 AM2/9/07
to

Thanks for your response, Larry. It's a ramdrive and when I tested it just
now it works fine. The PC been rebooted since the last test so that has
reset the XP randomiser.

Larry__Weiss

unread,
Feb 9, 2007, 11:14:42 AM2/9/07
to

I wish I had more information about how the CD command interprets
wildcard characters as a match to existing directory structure to
determine the new "current directory".

- Larry

0 new messages