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

Author Topic: Batch script to rename a word in vbs file  (Read 3546 times)

0 Members and 1 Guest are viewing this topic.

daillest319

    Topic Starter


    Beginner

    • Experience: Beginner
    • OS: Unknown
    Batch script to rename a word in vbs file
    « on: April 13, 2012, 08:06:36 AM »
    I'm trying to write a batch script to rename a certain word ina .vbs file.

    bascially i want it to find this...
    'S20120411
    change to...
    'S20120412

    so i want it to find S2012 or 'S2012 what ever easier and change 0411 to 0412 then the next day change 0412 to 0413 and so on for everyday but modifying the vbs file not making a copy.  as you can see its the date i was thinking maybe it can use the system date and paste it everyday if its possbile.

    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: Batch script to rename a word in vbs file
    « Reply #1 on: April 13, 2012, 08:11:35 AM »
    Seems like it would be easier for the vbscript to just pull the current date.

    daillest319

      Topic Starter


      Beginner

      • Experience: Beginner
      • OS: Unknown
      Re: Batch script to rename a word in vbs file
      « Reply #2 on: April 13, 2012, 08:36:21 AM »
      The thing is i have a vbs script thats going to automate through a webpage to download a file. Right now i have everything setup except for finding that file . The file name changes everyday to today's date and there no unqiue id for it so i get grab directly.
      I was thinking maybe use the following formula for the date in the batch script but i' m not sure if that would work.

      for /f "tokens=1-5 delims=/ " %%d in ("%date%")


      i have this code right now just need to make some changes..


      Code: [Select]
      @echo off
              SETLOCAL=ENABLEDELAYEDEXPANSION

              rename testfile.txt text.tmp
              for /f %%a in (text.tmp) do (
                  set foo=%%a
                  if !foo!==ex3 set foo=ex5
                  echo !foo! >> text.txt)
          del text.tmp
      « Last Edit: April 13, 2012, 09:01:37 AM by daillest319 »