Results 1 to 4 of 4

Thread: Anyone have Script to edit multiple files?

  1. #1
    Join Date
    Jan 2009
    Posts
    85

    Anyone have Script to edit multiple files?

    Hi friends ,
    Can anyone tell me how to write a script that will edit multiple text files? File can have extensions as *.htm, *.ini, and *.xml etc. etc. It will perform the actions such as finding or replacing the text words and adding or removing comments. I am regular user of this forum and know that I will get answer about it. Thank you in advance.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Anyone have Script to edit multiple files?

    Hi, I have got on internet something which is helpful to you. You can try this whether it is working or not? You need to do steps as follow:

    1.Open Notepad, paste the below script :

    @echo off
    REM — Prepare the Command Processor –
    SETLOCAL ENABLEEXTENSIONS
    SETLOCAL DISABLEDELAYEDEXPANSION

    ::BatchSubstitude – parses a File line by line and replaces a substring”
    ::syntax: BatchSubstitude.bat OldStr NewStr File
    :: OldStr [in] – string to be replaced
    :: NewStr [in] – string to replace with
    :: File [in] – file to be parsed
    if “%*”==”" findstr “^::” “%~f0″&GOTO:EOF
    for /f “tokens=1,* delims=]” %%A in (’”type %3|find /n /v “”"‘) do (
    set “line=%%B”
    if defined line (
    call set “line=echo.%%line:%~1=%~2%%”
    for /f “delims=” %%X in (’”echo.”%%line%%”"‘) do %%~X
    ) ELSE echo.
    )

    2. Save the file as “change.bat”

    The above script will parses a file line by line and will replaces a desired substring.

    3. Open cmd prompt >> type the following command:

    c:\change.bat “text-to-replace” text-to-replace-with c:\FileToEdit.txt > c:\Edited_file.txt

    Reply me whether it is working or not?

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Anyone have Script to edit multiple files?

    Hi, you can check for the script which I have made. This will solve your problem. You can try it as you need a script to edit multiple files. I think batch file will be better solution for you. Try this script. It have the capability to replace all "ABC" in files *.html to "XYZ".

    Steps to Follow:

    Get a list of .html files.
    var str list ; lf -n "*.html" > $list

    File loop.
    while ($list <> "")
    do

    Read in the next file.
    var str file ; lex "1" $list > $file
    var str content ; cat $file > $content

    Replace "ABC" to "XYZ".
    sal "^ABC^" "XYZ" $coontent > null

    Write file back.
    echo $content > { echo $file }
    done

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    Re: Anyone have Script to edit multiple files?

    I don't know how to do this. But find something on internet regarding how to wtite script to edit multiple files? Look at it and check whether it is helping you or not?


    var str list ; lf -n "*.html" > $list

    while ($list <> "")
    do

    var str file ; lex "1" $list > $file
    var str content ; cat $file > $content

    sal "^ABC^" "XYZ" $content > null

    echo $content > { echo $file }

Similar Threads

  1. How to edit multiple hyperlinks of Excel at a single time
    By De-Dg in forum MS Office Support
    Replies: 5
    Last Post: 24-02-2012, 12:15 PM
  2. Replies: 1
    Last Post: 20-04-2011, 06:15 PM
  3. Create a php script to replace a string in multiple files
    By KADEEM in forum Software Development
    Replies: 4
    Last Post: 23-11-2009, 05:09 PM
  4. Replies: 3
    Last Post: 14-05-2009, 10:25 AM
  5. Script to create multiple groups
    By Saphire in forum Active Directory
    Replies: 1
    Last Post: 18-08-2008, 11:51 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,511,757.29865 seconds with 17 queries