Jump to content

Find and replace texts in multiple files


Recommended Posts

I'm in a requirement to:

  1. Open multiple files in multiple directories (not all files are .txt files, some are .ini, some without extension). Example: c:\dir\subdir\file1, c:\dir\subdir\file2.ini, c:\dir2\file3
  2. Find 5 or 6 text strings in above files, string may contain special characters (Ex: %hostname%_a1234)
  3. Replace them with new string values
  4. Take backup of old files and save the updated files.

I've tried few scripts and couldn't get the solution.

Appreciate if anybody could help me to achieve this script.

Thanks in advance.

 

Link to comment
Share on other sites

1 hour ago, DeeJay7 said:

I'm in a requirement to:

  1. Open multiple files in multiple directories (not all files are .txt files, some are .ini, some without extension). Example: c:\dir\subdir\file1, c:\dir\subdir\file2.ini, c:\dir2\file3
  2. Find 5 or 6 text strings in above files, string may contain special characters (Ex: %hostname%_a1234)
  3. Replace them with new string values
  4. Take backup of old files and save the updated files.

I've tried few scripts and couldn't get the solution.

Appreciate if anybody could help me to achieve this script.

Thanks in advance.

 

Do any of the locations have anything in common?  Is it every single file in the directory c:\dir?

Do the strings youre trying to find have anything in common?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...