Computing.Net > Forums > Programming > Batch Find and replace single words

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Find and replace single words

Reply to Message Icon

Name: macuiare
Date: November 29, 2008 at 01:40:14 Pacific
OS: windows XP
CPU/Ram: AMD anthlon Duel 64x2 2gb
Product: asus
Comment:

Hello, Ive been having issues trying to replace single text, this question has been answerd before but it seems to remove all text before it deaming the code usless

Im trying to get the users to input something %a% which before replaced is n1

:ADD1
cls
Find /V n1 < Myfile.bat > %TEMP%.\Myfile.tmp
Echo %a% >>%TEMP%.\Myfile.tmp
Copy %TEMP%.\Myfile.tmp Myfile.bat
Del %TEMP%.\Myfile.tmp
cls

section with n1
note: N1 and N2 are all I am wanting to replace with %a% and %b% but when a user inputs something it finds the N1 and replaces everything before it aswell


ren n1 "control panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren n2 "control panel1.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control panel1.{21EC2020-3AEA-1069-A2DD-08002B30309D}"

thanks

Duke



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: November 29, 2008 at 04:10:20 Pacific
Reply:

You got me mystified.

Maybe post a before and after example.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: macuiare
Date: November 29, 2008 at 10:27:58 Pacific
Reply:

I'm getting the user to input something, that input replaces one word in a string which is in the same or batch file

cls
@echo off
:NAME1
cls
echo ________________________________________________________________________________
set /p a="First Folder's name that you want to hide: "
echo ________________________________________________________________________________
echo so you want to be able to hide %a% yes or no?
echo ________________________________________________________________________________
pause > nul
set/p "input=>"
if %input%==N goto NAME1
if %input%==n goto NAME1
if %input%==no goto NAME1
if %input%==Y goto ADD1
if %input%==y goto ADD1
if %input%==yes goto ADD1

:ADDAN1
echo ________________________________________________________________________________
echo Would you like to add another Hideable folder yes or no?
echo ________________________________________________________________________________
pause > nul

set/p "input=>"
if %input%==N goto END
if %input%==n goto END
if %input%==no goto END
if %input%==Y goto ADDAN1
if %input%==y goto ADDAN1
if %input%==yes goto ADDAN1


:ADD1
cls
Find /V n1 < Myfile.bat > %TEMP%.\Myfile.tmp
Echo %a% >>%TEMP%.\Myfile.tmp
Copy %TEMP%.\Myfile.tmp Myfile.bat
Del %TEMP%.\Myfile.tmp


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Find and replace single words

Batch find and replace www.computing.net/answers/programming/batch-find-and-replace/15145.html

Find and Replace text in Batch File www.computing.net/answers/programming/find-and-replace-text-in-batch-file/12413.html

Find and replace www.computing.net/answers/programming/find-and-replace/14659.html