DOS Command Help

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MartyBASS
Posts: 1
Joined: 21 Oct 2021 22:15

DOS Command Help

#1 Post by MartyBASS » 21 Oct 2021 22:21

DOS command to display all files on drive C whose filenames begin with the letter G and whose extensions begin with the letter D
DOS command to rename all the files on drive A which have the .HTML filename extension to have the .HTM filename extension.

atfon
Posts: 129
Joined: 06 Oct 2017 07:33

Re: DOS Command Help

#2 Post by atfon » 22 Oct 2021 07:01

Just a quick hint. For the first question, have a look at the documentation of the where command. For the second have a look at the documentation of for /r.

https://ss64.com/nt/where.html

https://ss64.com/nt/for_r.html

Gwarn_
Posts: 3
Joined: 29 Oct 2021 03:41

Re: DOS Command Help

#3 Post by Gwarn_ » 29 Oct 2021 04:07

Hi,

remenber * character ( multiple returns , lambda sign ), It's from "Dos" sure.

dir *.* ==> all files and folders ( in current folder only )
dir *. ==> folders ( in current folder only )

playing with "location of the * "
I look for files with AM in name , and so AN in extension :
dir *AM*.*AN* ( it's the syntax for my search in the current folder ).

* is 0, or more characters, it's an undefined number of character(s).

EXTENSIONs are more than 3 letters now , so "dir *.AM*IN" can have positive feedbacks, the console show by default 3 chars as extensions ( good to know ).
=====================================================
How to crawl all my C partition and search in ?

dir /s *.* ==> will display all visible files in your C: , one folder after the other.
It's /s for "sub" directory", so a recursive search is executed from the current folder ( from Windows 95/98 ) and through the sub directories of your current folder.


with Dos commands :
use HELP or /? to have details about the command you want to execute.
It's helpful

=====================================================
for your needs :
dir /s c:\G*.D*

for the "big" rename , through a loop but it's composite use of rename and so "a list" of the target you need.
It's risky, because of faulty through a full disk

try : rename *.HTML *.HTM ( this one is ok ; in one folder )
but ensure you're in the "only good folders"
the prototype is rename [path:filename_from] [path:filename_to] with the full path it's avoiding errors and random renaming.

Bye.

Squashman
Expert
Posts: 4354
Joined: 23 Dec 2011 13:59

Re: DOS Command Help

#4 Post by Squashman » 29 Oct 2021 12:36

Gwarn_ wrote:
29 Oct 2021 04:07
dir *. ==> folders ( in current folder only )
Incorrect.
That will list any files without an extension and directories without a period.

Gerhard
Posts: 11
Joined: 25 Oct 2021 22:01

Re: DOS Command Help

#5 Post by Gerhard » 30 Oct 2021 00:11

ok, so firstly, is this really DOS? or Windows cmd?

anyway, to list the files in current directory:

Code: Select all

dir /b /a-d G* D*
add /s if you want run through subdirectories as well.

on the rename of html files, That will really depend on more information. a simply rename *.html *.htm will rename files in the specific dir fine, but there might be particular files you do not want to rename. Is there a relationship between listing the files starting with D and G and the html file rename?

atfon
Posts: 129
Joined: 06 Oct 2017 07:33

Re: DOS Command Help

#6 Post by atfon » 01 Nov 2021 06:30

This is another way to list all "files on drive C whose filenames begin with the letter G and whose extensions begin with the letter D:"

Code: Select all

where /r C:\ G*.D*

Gwarn_
Posts: 3
Joined: 29 Oct 2021 03:41

Re: DOS Command Help

#7 Post by Gwarn_ » 03 Nov 2021 01:31

Gerhard wrote:
30 Oct 2021 00:11
ok, so firstly, is this really DOS? or Windows cmd?
It's DOS 'disk operating system'.
It's a root of your Windows, a real WIndows resource too.
It's Microsoft when GUI was not written at that time ( ( year 1980' ??? ).
It's both really.



About WHERE and DIR , I note ( while reading SS64 ), that dir will execute a "binary search" while crawling, opposite to where making a less accurate ( or wider ) search,
so using where, if you look for "myfile.txt" , the research will return "myfile.bat" ; "myfale.txt" and so an so , It's a research "by string" and schemas of strings.
it could be great when approximate search , or large extended search required.
It's "hard search" [binary base] or "soft search" [strings base and schemas].

atfon
Posts: 129
Joined: 06 Oct 2017 07:33

Re: DOS Command Help

#8 Post by atfon » 03 Nov 2021 06:34

Gwarn_ wrote:
03 Nov 2021 01:31
Gerhard wrote:
30 Oct 2021 00:11
ok, so firstly, is this really DOS? or Windows cmd?
It's DOS 'disk operating system'.
It's a root of your Windows, a real WIndows resource too.
It's Microsoft when GUI was not written at that time ( ( year 1980' ??? ).
It's both really.


It's a research "by string" and schemas of strings.
it could be great when approximate search , or large extended search required.
It's "hard search" [binary base] or "soft search" [strings base and schemas].
I cannot say without confirmation, but I sincerely doubt the OP is using the command.com command line interpreter for MS-DOS (or other versions of DOS) or Windows versions up to Me. The command line interpreter for Windows NT systems is cmd.exe, which is very different. Also, the OP's question was about a large extended search.

Post Reply