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

Author Topic: 3 questions  (Read 3301 times)

0 Members and 1 Guest are viewing this topic.

devcom

    Topic Starter


    Apprentice

    Thanked: 37
    3 questions
    « on: December 09, 2007, 02:32:46 PM »
    1. How can i make bat wich will make files in random folders ?
    2. It is possible to code/decode text e.g. in rot13 ??
    i dont wont do it in "for" etc
    3. How to find in files text from one word to other ?
    like i wont to find tex2 form txt1 to txt3
    Code: [Select]
    txt1           txt2            txt3thanks in advance
    our friend Dusty says me to post config etc  ;)
    so:
    Vista/XP
    4gb RAM
    Intel QX6850
    Striker Extreme
    2x 8800Ultra OC SLI
    Download: Choice.exe

    devcom

      Topic Starter


      Apprentice

      Thanked: 37
      Re: 3 questions
      « Reply #1 on: December 10, 2007, 08:38:44 AM »
      Anybody know?? Please
      Download: Choice.exe

      diablo416

      • Guest
      Re: 3 questions
      « Reply #2 on: December 10, 2007, 09:29:52 AM »
      1)
      mkdir %random%

      2)unsure about in the command window but otherways easily google it

      3)use findstr string file.txt unsure what you mean "one word to other"

      example:
      cd\myfiles
      findstr /I Titlename *.txt

      would search *.txt (all text files) in (myfiles) folder, and display ones with "Titlename" in them  /I is ignore string case

      devcom

        Topic Starter


        Apprentice

        Thanked: 37
        Re: 3 questions
        « Reply #3 on: December 10, 2007, 09:55:01 AM »
        thanx!
        but about the 3 question. I wont to find "some text" in eg test.txt betwen "before word" to "after word"
         "before word" "some text" "after word"
        Download: Choice.exe

        gpl



          Apprentice
        • Thanked: 27
          Re: 3 questions
          « Reply #4 on: December 10, 2007, 10:40:46 AM »
          You will need to use the regular expression function in FindStr
          Type FindStr /? at the command prompt to see the options

          If you only want to find 'myword' between 'firstword' and 'lastword', separated only by a single space, then you can search for

          firstword myword lastword

          But if there are varying amounts of space, commas tabs etc between, then the regular expression is the way to go

          Graham

          devcom

            Topic Starter


            Apprentice

            Thanked: 37
            Re: 3 questions
            « Reply #5 on: December 10, 2007, 12:09:07 PM »
            Yes but what will be if i dont have 'myword' but the oders
            Download: Choice.exe

            ghostdog74



              Specialist

              Thanked: 27
              Re: 3 questions
              « Reply #6 on: December 10, 2007, 07:07:07 PM »
              here's some vbscript code to get you started.
              Code: [Select]
              ' 1) create directory with random number
              Randomize
              numRandom = Int((65535 * Rnd) + 1)
              WScript.Echo numRandom
              Set objFSO=CreateObject("Scripting.FileSystemObject")
              objFSO.CreateFolder("C:\temp\" & numRandom) 'create directory

              '2) rot13 encrypt
              strInput = "testing"
              n = 13
              For i = 1 To Len(strInput)
                  strConverted = Chr(Asc(Mid(strInput, i, 1)) + n)
              WScript.StdOut.Write(strConverted)
              Next


              '2) rot13 decrypt
              strInput = "testing"
              n = 13
              For i = 1 To Len(strInput)
                  strConverted = Chr(Asc(Mid(strInput, i, 1)) - n)
              WScript.StdOut.Write(strConverted)
              Next

              WScript.Echo

              ' 3) find words between 2 words
              strTest = "txt1    tex2       txt2"
              indexFirstWord = InStr(1,strTest,"txt1")
              WScript.Echo indexFirstWord
              indexSecondWord = InStr(1,strTest,"txt2")
              WScript.Echo indexSecondWord
              indexstart = indexFirstWord + Len("txt1")
              strWordBetween = Trim(Mid(strTest,indexstart,indexSecondWord - indexstart))
              WScript.Echo strWordBetween

              devcom

                Topic Starter


                Apprentice

                Thanked: 37
                Re: 3 questions
                « Reply #7 on: December 17, 2007, 09:50:59 AM »
                that 3 is impossible in .bat file ?? coz i cant make it work in vbs
                Download: Choice.exe