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

Author Topic: Search file and edit it  (Read 14630 times)

0 Members and 1 Guest are viewing this topic.

ghostdog74



    Specialist

    Thanked: 27
    Re: Search file and edit it
    « Reply #15 on: March 24, 2011, 07:43:40 PM »
    Here ya go.  You needed two ">>".  This will find it, and "append" to the end of the original text you use, not replace it.

    cd\
    dir/s/p/b \*.vdf >> test.vdf

    did you understand what the question is about? 

    Apexi

      Topic Starter


      Rookie

      Re: Search file and edit it
      « Reply #16 on: March 29, 2011, 12:14:25 PM »
      what happens if you put

      echo "%%~dpnxA"

      in the script?

      and what's with the second wildcard in this?

      *text.vdf*.*

      I suspect it's not finding anything, as it's looking for a file with 2 dots

      The same as before. I end up in C:\ And i know that the file is there, i'm looking at it right now :P

      Salmon Trout

      • Guest
      Re: Search file and edit it
      « Reply #17 on: March 29, 2011, 12:27:40 PM »
      You didn't answer this question:

      Quote from: Me, before
      and what's with the second wildcard in this?

      *text.vdf*.*

      and did you read this?

      Quote
      I suspect it's not finding anything, as it's looking for a file with 2 dots

      You wrote:

      Quote
      And i know that the file is there, i'm looking at it right now

      Go on, take a giant step for mankind and tell us what it is called!



      Apexi

        Topic Starter


        Rookie

        Re: Search file and edit it
        « Reply #18 on: March 29, 2011, 12:33:49 PM »
        You didn't answer this question:

        and did you read this?

        You wrote:

        Go on, take a giant step for mankind and tell us what it is called!

        Forget the other wildcard. Just me who made a misstake. Dis'nt matter iaf i remove the second wildcard. Same as before. Also, if i just type *text.vdf*.* in cmd it will find the file :P

        Salmon Trout

        • Guest
        Re: Search file and edit it
        « Reply #19 on: March 29, 2011, 12:37:22 PM »
        Why aren't you telling us the name of the file you were "looking at"? Are you playing a game with us? If you want to get help here, it is good manners to answer the questions that are asked by the people who are trying to help you, and who, for the time being, are still inclined to treat you as a genuine questioner and not anything else.

        By the way, in your original post, you mentioned a file called "test.vdf", with an 's', but all your search wildcards seem to be looking for a file with "text", with an 'x', in the name. Perhaps you could talk us through what this means?


        Apexi

          Topic Starter


          Rookie

          Re: Search file and edit it
          « Reply #20 on: March 29, 2011, 12:46:37 PM »
          Well i dis'nt seemes like you want to help. What more do you need to know, it is a vdf file named test. Anyhow, then i have to look for another forum.

          Salmon Trout

          • Guest
          Re: Search file and edit it
          « Reply #21 on: March 29, 2011, 12:48:48 PM »
          it is a vdf file named test.

          So why are you looking for a file called text*.vdf?


          Apexi

            Topic Starter


            Rookie

            Re: Search file and edit it
            « Reply #22 on: March 29, 2011, 12:50:55 PM »
            So why are you looking for a file called text*.vdf?

            Because i want to edit it.

            Salmon Trout

            • Guest
            Re: Search file and edit it
            « Reply #23 on: March 29, 2011, 12:56:10 PM »
            Because i want to edit it.

            Are you serious? If the file is called test.vdf, and your search batch script is looking for text.vdf, then your batch script is never going to find it. Don't you understand that? It's like calling out "Jim!" when there is nobody called Jim in the room, and you actually wanted John to answer anyway. A waste of time. (Like this thread)



            Apexi

              Topic Starter


              Rookie

              Re: Search file and edit it
              « Reply #24 on: March 29, 2011, 01:03:32 PM »
              It never accord to you that it could be a misspelling? Or it doesnt matter what the file is named. Or maybe that i could change the script later on. Do me a favour. If you cant help, dont say any. Instead of being a jerk with no helpfull answer.

              Allan

              • Moderator

              • Mastermind
              • Thanked: 1260
              • Experience: Guru
              • OS: Windows 10
              Re: Search file and edit it
              « Reply #25 on: March 29, 2011, 01:12:27 PM »
              Okay guys, let's knock it off.

              ST - you always have the option of not posting in this thread anymore - your choice

              apexi - I can't follow what you want to do either - you've been less than clear and consistent in this thread. Also, let's be overtly rude to anyone, okay?

              Salmon Trout

              • Guest
              Re: Search file and edit it
              « Reply #26 on: March 29, 2011, 01:35:57 PM »
              Deep in a sub folder on my S drive is a file called test.vdf. This script finds it and shows its name and folder and adds 2 lines of text to it.

              test.vdf (located in folder S:\Oldfolders\T-Drive\upix\sub1\sub2\sub3\sub4)

              Code: [Select]
              ; this is test.vdf
              ; it has 2 lines

              The batch script:

              Code: [Select]
              @echo off
              for /f "delims==" %%A in ('dir /b /s S:\*.vdf') do (
                  echo file name:   %%~nxA
                  echo file folder: %%~dpnxA
                  echo Before:
                  type "%%~dpnxA"
                  echo ; extra line 1 >> %%~dpnxA
                  echo ; extra line 2 >> %%~dpnxA
                  echo After:
                  type "%%~dpnxA"
                  )

              The console output:
              Code: [Select]
              S:\>findvdf.bat
              file name:   Test.vdf
              file folder: S:\Oldfolders\T-Drive\upix\sub1\sub2\sub3\sub4\Test.vdf
              Before:
              ; this is test.vdf
              ; it has 2 lines
              After:
              ; this is test.vdf
              ; it has 2 lines
              ; extra line 1
              ; extra line 2

              Salmon Trout

              • Guest
              Re: Search file and edit it
              « Reply #27 on: March 29, 2011, 03:51:17 PM »
              [Edit]

              Code: [Select]
              @echo off
              for /f "delims==" %%A in ('dir /b /s S:\*.vdf') do (
                  echo file name:   %%~nxA
                  echo file folder: %%~dpA
                  echo Before:
                  type "%%~dpnxA"
                  echo ; extra line 1 >> %%~dpnxA
                  echo ; extra line 2 >> %%~dpnxA
                  echo After:
                  type "%%~dpnxA"
                  )   

              Code: [Select]
              S:\>findvdf.bat
              file name:   Test.vdf
              file folder: S:\Oldfolders\T-Drive\upix\sub1\sub2\sub3\sub4
              Before:
              ; this is test.vdf
              ; it has 2 lines
              After:
              ; this is test.vdf
              ; it has 2 lines
              ; extra line 1
              ; extra line 2

              BC_Programmer


                Mastermind
              • Typing is no substitute for thinking.
              • Thanked: 1140
                • Yes
                • Yes
                • BC-Programming.com
              • Certifications: List
              • Computer: Specs
              • Experience: Beginner
              • OS: Windows 11
              Re: Search file and edit it
              « Reply #28 on: March 29, 2011, 06:15:39 PM »
              It never accord to you that it could be a misspelling?
              Which one was the misspelled one? test or text?
              I was trying to dereference Null Pointers before it was cool.

              Apexi

                Topic Starter


                Rookie

                Re: Search file and edit it
                « Reply #29 on: March 31, 2011, 11:51:22 AM »
                Everything is solved. After some conversation with Salmon Trout and a big pile of help the script works properly.