1.

Solve : How to search and replace text in file using batch file?

Answer»

I have file c:/name/param.txt which has below COMMAND.
$Inputfile=xxxxx_03122012.gpg


New file xxxxx_03292012.gpg is present in c:/name.

I WANT to write a batch file which will check if any file ‘xxxxx_*.gpg’ exists in directory c:/name, replace ‘$Inputfile=xxxxx_03122012.gpg’ in param.txt with ‘$Inputfile=xxxxx_03292012.gpg’. Then move xxxxx_03292012.gpg to c:/name/archieve.

Can this be possible to do in batch file?
Quote

Can this be possible to do in batch file?
Yes. But let me ask if this is homework or a task you want to do just because it is hard. It sure is hard for me. Too easy to make a mistake.

For regular USE in a IT department, the logical choice is to use a script language that is more advanced that basic batch. It cam be used over again and easily modified by others.

PowerShell is recommended by Microsoft.

As for myself, I have a hard time with long STRINGS of letters and numbers. so I would use a high level script ton write a more abstract level of find and replace.

Also, some search and replace tools can be invoked from a batch file.

Still, if you just wait, somebody will be here to help you.Quote from: Rup on March 30, 2012, 12:17:13 PM
I have file c:/name/param.txt which has below command.
$Inputfile=xxxxx_03122012.gpg

Is this the only line in c:\name\param.txt, or are there other lines?


Discussion

No Comment Found