Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
just_iulia din Giurgiu
Femeie
25 ani
Giurgiu
cauta Barbat
26 - 48 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [WINDOWS] Replace Text in Multiple Files Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
TRaP
Moderator

Inregistrat: acum 7 ani
Postari: 869
I want to replace text strings in multiple VBS files.

Since nowadays the easiest way to do anything is ask the AI, I've did just that.

✅ 1. PowerShell – Easiest and Safest (recommended) - and best if you don't want to install new software (like for number 2, 4, or other options provided at the bottom of the post)
Works on any Windows system (built-in).

Replace a text string in all .vbs files inside a folder

Get-ChildItem "C:\path\to\folder" -Filter *.vbs -Recurse |
ForEach-Object {
    (Get-Content $_.FullName) -replace "oldText", "newText" |
    Set-Content $_.FullName
}

Notes:
- Replace oldText and newText with your actual strings.
- Add -Recurse if files are in subfolders.
- PowerShell’s -replace supports regex.
- If your text contains special regex characters, escape them or use -creplace.

✅ 2. Notepad++ – Very user-friendly - you can find NPP in portable version, and it's a really neat text editor especially if you do VBS

a. Open Notepad++
b. Press Ctrl+Shift+F → Find in Files
c. Set:
- Find what: old text
- Replace with: new text
- Directory: your folder
- Filters: *.vbs
d. Click Replace in Files

Advantages: preview, no scripting, easy undo of individual files.

✅ 3. CMD (Batch Script) - if all else fails

If you prefer a simple batch .cmd script:

@echo off
setlocal enabledelayedexpansion
set old=oldText
set new=newText

for %%f in (*.vbs) do (
    set file=%%f
    (for /f "delims=" %%l in (%%f) do (
        set "line=%%l"
        echo(!line:%old%=%new%!
    )) > temp.txt
    move /y temp.txt %%f > nul
)

But PowerShell is much easier and cleaner.

✅ 4. VS Code – Good if you already use it

1. Open the folder in VS Code
2. Press Ctrl+Shift+H
3. Enter Find and Replace texts
4. Files to include: *.vbs
5. Click Replace All

Source: ChatGPT

Other options previously posted by me include:
- Replsoft Useful File Utilities (UFU) + Batch Replacer plug-in:
- UFU tutorial, VBA option, or macro option within Excel:


pus acum 2 zile
   
Pagini: 1  

Mergi la