Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Listing Seven Character Text Files on Root Drive  (Read 11744 times)

0 Members and 1 Guest are viewing this topic.

nzidiot

  • Guest
Listing Seven Character Text Files on Root Drive
« 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
« Last Edit: May 09, 2009, 12:17:46 AM by nzidiot »

Reno



    Hopeful
  • Thanked: 32
    Re: Listing Seven Character Text Files on Root Drive
    « Reply #1 on: May 09, 2009, 01:39:05 AM »
    dir/b c:\*.txt|findstr/r /i "^.......\.txt"

    gh0std0g74



      Apprentice

      Thanked: 37
      Re: Listing Seven Character Text Files on Root Drive
      « Reply #2 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

      gh0std0g74



        Apprentice

        Thanked: 37
        Re: Listing Seven Character Text Files on Root Drive
        « Reply #3 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.

        mroilfield



          Mentor
        • Thanked: 42
          • Yes
          • Yes
        • Computer: Specs
        • Experience: Experienced
        • OS: Windows 11
        Re: Listing Seven Character Text Files on Root Drive
        « Reply #4 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,
        You can't fix Stupid!!!

        gh0std0g74



          Apprentice

          Thanked: 37
          Re: Listing Seven Character Text Files on Root Drive
          « Reply #5 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)

          Reno



            Hopeful
          • Thanked: 32
            Re: Listing Seven Character Text Files on Root Drive
            « Reply #6 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??? :(

            Dias de verano

            • Guest
            Re: Listing Seven Character Text Files on Root Drive
            « Reply #7 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".


            gh0std0g74



              Apprentice

              Thanked: 37
              Re: Listing Seven Character Text Files on Root Drive
              « Reply #8 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:)

              gh0std0g74



                Apprentice

                Thanked: 37
                Re: Listing Seven Character Text Files on Root Drive
                « Reply #9 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.

                Dias de verano

                • Guest
                Re: Listing Seven Character Text Files on Root Drive
                « Reply #10 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?


                Dias de verano

                • Guest
                Re: Listing Seven Character Text Files on Root Drive
                « Reply #11 on: May 09, 2009, 02:57:56 AM »
                huh ?

                It's a lame excuse to say that anything not specifically excluded is allowed.

                gh0std0g74



                  Apprentice

                  Thanked: 37
                  Re: Listing Seven Character Text Files on Root Drive
                  « Reply #12 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?

                  gh0std0g74



                    Apprentice

                    Thanked: 37
                    Re: Listing Seven Character Text Files on Root Drive
                    « Reply #13 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.

                    Dias de verano

                    • Guest
                    Re: Listing Seven Character Text Files on Root Drive
                    « Reply #14 on: May 09, 2009, 03:07:12 AM »
                    that's not up to you to decide.

                    Yes it is. I just appointed myself.

                    mroilfield



                      Mentor
                    • Thanked: 42
                      • Yes
                      • Yes
                    • Computer: Specs
                    • Experience: Experienced
                    • OS: Windows 11
                    Re: Listing Seven Character Text Files on Root Drive
                    « Reply #15 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?

                    You can't fix Stupid!!!

                    gh0std0g74



                      Apprentice

                      Thanked: 37
                      Re: Listing Seven Character Text Files on Root Drive
                      « Reply #16 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?


                      Dias de verano

                      • Guest
                      Re: Listing Seven Character Text Files on Root Drive
                      « Reply #17 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.


                      gh0std0g74



                        Apprentice

                        Thanked: 37
                        Re: Listing Seven Character Text Files on Root Drive
                        « Reply #18 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.

                        gh0std0g74



                          Apprentice

                          Thanked: 37
                          Re: Listing Seven Character Text Files on Root Drive
                          « Reply #19 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

                          kpac

                          • Web moderator


                          • Hacker

                          • kpac®
                          • Thanked: 184
                            • Yes
                            • Yes
                            • Yes
                          • Certifications: List
                          • Computer: Specs
                          • Experience: Expert
                          • OS: Windows 7
                          Re: Listing Seven Character Text Files on Root Drive
                          « Reply #20 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...

                          gh0std0g74



                            Apprentice

                            Thanked: 37
                            Re: Listing Seven Character Text Files on Root Drive
                            « Reply #21 on: May 09, 2009, 03:23:41 AM »
                            I have now...
                            good. on what grounds?

                            kpac

                            • Web moderator


                            • Hacker

                            • kpac®
                            • Thanked: 184
                              • Yes
                              • Yes
                              • Yes
                            • Certifications: List
                            • Computer: Specs
                            • Experience: Expert
                            • OS: Windows 7
                            Re: Listing Seven Character Text Files on Root Drive
                            « Reply #22 on: May 09, 2009, 03:24:38 AM »
                            Ah, "stfu". ::)

                            gh0std0g74



                              Apprentice

                              Thanked: 37
                              Re: Listing Seven Character Text Files on Root Drive
                              « Reply #23 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.

                              mroilfield



                                Mentor
                              • Thanked: 42
                                • Yes
                                • Yes
                              • Computer: Specs
                              • Experience: Experienced
                              • OS: Windows 11
                              Re: Listing Seven Character Text Files on Root Drive
                              « Reply #24 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.
                              You can't fix Stupid!!!

                              kpac

                              • Web moderator


                              • Hacker

                              • kpac®
                              • Thanked: 184
                                • Yes
                                • Yes
                                • Yes
                              • Certifications: List
                              • Computer: Specs
                              • Experience: Expert
                              • OS: Windows 7
                              Re: Listing Seven Character Text Files on Root Drive
                              « Reply #25 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.

                              gh0std0g74



                                Apprentice

                                Thanked: 37
                                Re: Listing Seven Character Text Files on Root Drive
                                « Reply #26 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

                                Dias de verano

                                • Guest
                                Re: Listing Seven Character Text Files on Root Drive
                                « Reply #27 on: May 09, 2009, 03:33:01 AM »

                                Reno



                                  Hopeful
                                • Thanked: 32
                                  Re: Listing Seven Character Text Files on Root Drive
                                  « Reply #28 on: May 09, 2009, 03:34:04 AM »
                                  Quote:
                                  Now now boys calm down  :)

                                  gh0std0g74



                                    Apprentice

                                    Thanked: 37

                                    kpac

                                    • Web moderator


                                    • Hacker

                                    • kpac®
                                    • Thanked: 184
                                      • Yes
                                      • Yes
                                      • Yes
                                    • Certifications: List
                                    • Computer: Specs
                                    • Experience: Expert
                                    • OS: Windows 7
                                    Re: Listing Seven Character Text Files on Root Drive
                                    « Reply #30 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.

                                    gh0std0g74



                                      Apprentice

                                      Thanked: 37
                                      Re: Listing Seven Character Text Files on Root Drive
                                      « Reply #31 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?

                                      kpac

                                      • Web moderator


                                      • Hacker

                                      • kpac®
                                      • Thanked: 184
                                        • Yes
                                        • Yes
                                        • Yes
                                      • Certifications: List
                                      • Computer: Specs
                                      • Experience: Expert
                                      • OS: Windows 7
                                      Re: Listing Seven Character Text Files on Root Drive
                                      « Reply #32 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.

                                      Dias de verano

                                      • Guest
                                      Re: Listing Seven Character Text Files on Root Drive
                                      « Reply #33 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.



                                      gh0std0g74



                                        Apprentice

                                        Thanked: 37
                                        Re: Listing Seven Character Text Files on Root Drive
                                        « Reply #34 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.

                                        Carbon Dudeoxide

                                        • Global Moderator

                                        • Mastermind
                                        • Thanked: 169
                                          • Yes
                                          • Yes
                                          • Yes
                                        • Certifications: List
                                        • Experience: Guru
                                        • OS: Mac OS
                                        Re: Listing Seven Character Text Files on Root Drive
                                        « Reply #35 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.