Csaba Gabor
09-21-2005, 03:04 PM
My editor (emacs) likes to make backups by placing a tilde (~) on the
end of the filename. If I then do a directory of that particular
filetype by means of:
dir *.typ
then I get a list like
file1.typ
file1.typ~
file2.typ
file2.typ~
....
Is there a way (especially using dir only (without piping)) to get only
the *.typ without the ~ at the end?
Thanks,
Csaba Gabor from New York
Michael Bednarek
09-22-2005, 02:11 AM
On 21 Sep 2005 07:04:30 -0700, "Csaba Gabor" <Csaba@z6.com> wrote in
microsoft.public.win2000.cmdprompt.admin:
>My editor (emacs) likes to make backups by placing a tilde (~) on the
>end of the filename. If I then do a directory of that particular
>filetype by means of:
>
>dir *.typ
>
>then I get a list like
>file1.typ
>file1.typ~
>file2.typ
>file2.typ~
>...
>
>Is there a way (especially using dir only (without piping)) to get only
>the *.typ without the ~ at the end?
AFAIK that's not easily done with the DIR command in
CMD.EXE/COMMAND.COM. The only way I can imagine would be indeed to pipe
DIR's output into FIND or FINDSTR, or a FOR loop which inspects the file
extension.
4NT can do it like this:
DIR /[!*.typ~]
The parameter /[!] specifies an exclusion range; see
<http://jpsoft.com/help/filexranges.htm>.
Alternatively, 4NT can be directed not to match short filenames with the
directive:
OPTION //Win32SFNSearch=No
and the command
DIR *.typ
will the show only those files. See
<http://jpsoft.com/help/lfnsearch.htm>.
I believe there is a similar directive for the free 4DOS
(Win95SFNSearch), but I doubt this would work under any NT-class OS; 4NT
is a commercial product.
--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
Tyler Moeller [MS]
09-22-2005, 04:18 AM
You might try something like the following:
for /f "tokens=*" %I in ('dir /b *.typ') do @if %~xI==.typ echo %I
This outputs:
file1.typ
file2.typ
If you want to list all four files, then try this:
for /f "tokens=*" %I in ('dir /b *.typ') do @if %~xI==.typ (echo %I) else
(echo %~nI.typ)
You will get the following:
file1.typ
file1.typ
file2.typ
file2.typ
Hope this helps,
-Tyler
--
____________________________________________________
This information is provided "AS IS" with no warranties and confers no
rights.
"Csaba Gabor" <Csaba@z6.com> wrote in message
news:1127311470.869390.73700@f14g2000cwb.googlegroups.com...
| My editor (emacs) likes to make backups by placing a tilde (~) on the
| end of the filename. If I then do a directory of that particular
| filetype by means of:
|
| dir *.typ
|
| then I get a list like
| file1.typ
| file1.typ~
| file2.typ
| file2.typ~
| ...
|
| Is there a way (especially using dir only (without piping)) to get only
| the *.typ without the ~ at the end?
|
| Thanks,
| Csaba Gabor from New York
|
The fact that "dir *.typ" also displays *.typ* is caused by the behaviour
how the file system creates short file names.
If you don't want the files *.typ* to be displayd you can change this in the
registry:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"Win95TruncatedExtensions"=dword:00000000
But this works only for files that are created after the change in the
registry was made.
If you want to do the changes for all old files you have to copy all files
od a certain drive to a different drive, delete the original files and copy
them back again.
Konrad Kullig
"Csaba Gabor" <Csaba@z6.com> schrieb im Newsbeitrag
news:1127311470.869390.73700@f14g2000cwb.googlegroups.com...
> My editor (emacs) likes to make backups by placing a tilde (~) on the
> end of the filename. If I then do a directory of that particular
> filetype by means of:
>
> dir *.typ
>
> then I get a list like
> file1.typ
> file1.typ~
> file2.typ
> file2.typ~
> ...
>
> Is there a way (especially using dir only (without piping)) to get only
> the *.typ without the ~ at the end?
>
> Thanks,
> Csaba Gabor from New York
>