Computer Hope

Microsoft => Microsoft DOS => Topic started by: nzidiot on May 08, 2009, 09:59:04 PM

Title: Listing Seven Character Text Files on Root Drive
Post by: nzidiot on May 08, 2009, 09:59:04 PM
Hi

For an assignment i have, i have to, in a batch file, List all text files whose names are seven characters long on the whole C: Drive - make the listing output in wide format and then output the listing to a file.

I know how to save the results to a file

> (file name)

I know the command for listing files on the C Drive

DIR C:\ /S /W .txt

The /s being to include sub folders in search and the /w being display the listing in wide format. The .txt being the file format i want to search for.

The command im stuck with is listing only 7 character files. Please help


Thanks
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: Reno on May 09, 2009, 01:39:05 AM
dir/b c:\*.txt|findstr/r /i "^.......\.txt"
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 01:41:03 AM
if your assignment is not restricted to batch: here's a vbscript. it assumes total length of filename including extension.
Code: [Select]
Set objFS = CreateObject("Scripting.FileSystemObject")
strFolder = "c:\"
Set objFolder = objFS.GetFolder(strFolder)
Sub ScanDir (objFolder)
For Each strDir In objFolder.SubFolders
ScanDir(strDir)
Next
For Each strFile In objFolder.Files
If Len(strFile.Name) = 7 And objFS.GetExtensionName(strFile.Name) = "txt" Then
WScript.Echo "do something here"
End If
Next
End Sub
ScanDir objFolder
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 01:46:28 AM
dir/b c:\*.txt|findstr/r /i "^.......\.txt"
its whole c drive, therefore needs /s. after that, the regular expression for findstr will be different.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: mroilfield on May 09, 2009, 01:54:47 AM
if your assignment is not restricted to batch

gh0stg0g74,

I think you missed the part of the original post that said the assignment was in batch

For an assignment i have, i have to, in a batch file,
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 02:32:47 AM
gh0stg0g74,
I think you missed the part of the original post that said the assignment was in batch
He didn't say it should be in "pure batch" either. anyway, to choose to use my solution or not, is entirely up to OP, so i think you shouldn't worry too much about how or what i post (as long as it solves the problem)
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: Reno on May 09, 2009, 02:41:13 AM
its whole c drive, therefore needs /s. after that, the regular expression for findstr will be different.

for whole c drive, longer code:
Code: [Select]
dir/b/s *.txt|findstr/rei "\\[^\\][^\\][^\\][^\\][^\\][^\\][^\\]\.txt"
gh0stg0g74,

I think you missed the part of the original post that said the assignment was in batch
::) oh no, it's for assignment??? :(
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: Dias de verano on May 09, 2009, 02:42:13 AM
He didn't say it should be in "pure batch" either.

he didn't say the answers should be written in Sanskrit either.

Quote from: OP
For an assignment i have, i have to, in a batch file

That is so ambiguous! The words "a batch file"could mean anything! Like "any scripting language that I can brag about knowing a bit about".

Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 02:48:08 AM
::) oh no, it's for assignment??? :(
doesn't matter as there is still something missing in your solution, so let OP find out for himself. still alright i guess:)
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 02:52:09 AM
he didn't say the answers should be written in Sanskrit either.
huh ?

Quote
That is so ambiguous! The words "a batch file"could mean anything! Like "any scripting language that I can brag about knowing a bit about".
isn't this a fact already well known? unless specifically mentioned that pure batch is needed, a batch file can mean anything.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: Dias de verano on May 09, 2009, 02:56:44 AM
a batch file can mean anything.

That is a laughably idiotic remark.

You don't give up, do you?

Title: Re: Listing Seven Character Text Files on Root Drive
Post by: Dias de verano on May 09, 2009, 02:57:56 AM
huh ?

It's a lame excuse to say that anything not specifically excluded is allowed.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 03:03:37 AM
That is a laughably idiotic remark
you don't think deep , do you? you should watch your language, you are not a school kid anymore, are you?
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 03:06:02 AM
It's a lame excuse to say that anything not specifically excluded is allowed.
that's not up to you to decide.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: Dias de verano on May 09, 2009, 03:07:12 AM
that's not up to you to decide.

Yes it is. I just appointed myself.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: mroilfield on May 09, 2009, 03:11:58 AM
(as long as it solves the problem)

How is giving him a solution in VBScript going to solve his problem when he needs it in batch?

Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 03:14:40 AM
How is giving him a solution in VBScript going to solve his problem when he needs it in batch?
if you don't like my post, why don't you report to the moderator? if not, why should you care ?

Code: [Select]
@echo off
cscript /nologo myscript.vbs
save the above as myscript.bat, and there's your batch. anything wrong?

Title: Re: Listing Seven Character Text Files on Root Drive
Post by: Dias de verano on May 09, 2009, 03:15:38 AM
if you don't like my post, why don't you report to the moderator? if not, why should you care ?

Pendejo.

Quote
save the above as myscript.bat, and there's your batch. anything wrong?

Plenty. You sure are getting like a troll.

Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 03:18:30 AM
Pendejo.

Plenty. You sure are getting like a troll.


you look more like a troll to me.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 03:19:18 AM
Plenty. You sure are getting like a troll.
so can you tell what's wrong? if not, stfu
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: kpac on May 09, 2009, 03:22:38 AM
if you don't like my post, why don't you report to the moderator?

I have now...
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 03:23:41 AM
I have now...
good. on what grounds?
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: kpac on May 09, 2009, 03:24:38 AM
Ah, "stfu". ::)
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 03:26:43 AM
Ah, "stfu". ::)
good. since you have free time, how about reporting post #10 and #17 for me. those 2 posts really piss me off and rude , so i think its only fair you report them as well.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: mroilfield on May 09, 2009, 03:29:16 AM
Nzidiot,

Let me apologize to you for post that aren't helping you with your problem. Normally the people that post here are able to give you good guidance with out all the fuss.

Sorry for any confusion or frustration caused on my part.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: kpac on May 09, 2009, 03:30:08 AM
good. since you have free time, how about reporting post #10 and #17 for me. those 2 posts really piss me off and rude , so i think its only fair you report them as well.

Free time? So what exactly are you doing on here? And I would report those other 2 posts if I agreed with you, but I don't. You're missing the point entirely. I don't understand how you don't see that the OP want's batch, and yet you still give it in VBS.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 03:32:45 AM
Free time? So what exactly are you doing on here? And I would report those other 2 posts if I agreed with you, but I don't. You're missing the point entirely. I don't understand how you don't see that the OP want's batch, and yet you still give it in VBS.
how do you define batch? give me a real answer
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: Dias de verano on May 09, 2009, 03:33:01 AM
I have now...

me too.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: Reno on May 09, 2009, 03:34:04 AM
Quote:
Now now boys calm down  :)
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 03:34:26 AM
me too.
me too.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: kpac on May 09, 2009, 03:35:19 AM
how do you define batch? give me a real answer
me too.

Grow up for God's sake.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 03:36:39 AM
Grow up for God's sake.
you can't answer me? then where's is that justification that what i do is wrong?
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: kpac on May 09, 2009, 03:37:55 AM
you can't answer me? then where's is that justification that what i do is wrong?

Exactly I can't answer you, because I don't know batch. But I do know how to run a forum.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: Dias de verano on May 09, 2009, 03:38:14 AM
how do you define batch? give me a real answer

In DOS, OS/2, and Microsoft Windows, a batch file is a text file containing a series of commands intended to be executed by the command interpreter. The OP mentioned a C: drive, so it's a pretty fair bet he or she is using one of these. It is also a fair bet, since the OP appears to be seeking the solution to a school assignment, and from a careful reading of the question, that the desired outcome is to demonstrate competence in using fairly simple features, such as command output redirection, DIR switches such as /W and /S and wildcards. I think the assignment is more likely to find files of 7 characters or less  in the filename.


Title: Re: Listing Seven Character Text Files on Root Drive
Post by: gh0std0g74 on May 09, 2009, 03:42:00 AM
Exactly I can't answer you, because I don't know batch.
wow, you do not know batch, BUT you can tell what's right or wrong? gimme a break.

Quote
But I do know how to run a forum.
no you don't. If you are really running this forum, as in doing the administration/design etc..you would state clearly that anything other than batch are not allowed, only then I will not post in VBscript or any other languages i know.
Title: Re: Listing Seven Character Text Files on Root Drive
Post by: Carbon Dudeoxide on May 09, 2009, 03:46:44 AM
Wow, a flood of topic reports...

Dias, Ghostdog, settle this elsewhere. That's what PMs are for.

Topic Closed. If anyone wants this reopened for any reason, please PM me.


Kpac is right in one thing. He doesn't go around trying to boost his post count with useless remarks.