Sign in to follow this  
Followers 0
MWIDNER21

Find and replace

5 posts in this topic

hello, I am currently working on a project to move data from one server to another. This would normally be easy but we are changing where the applications are hosted. So to move the server data, i have to also go into every profile on the new server (200+) and change where their shortcuts point to. Also i have to go into another folder which we are moving and change a string in a text file in all folders (200+) to the new location as well. I know how to do a replace string within a text file, but to have a script go into each folder and change a string within a single text file and also change all shortcuts(which may reside in the startup, quick launch, and programs) seems daunting. Does anyone know how i can accomplish this and if it is even possible?

Thanks! :x

Share this post


Link to post
Share on other sites



I can recommend Melba23's recursive file finder.

But I can't immediately find the link.

It searches recursively and lets you do stuff for each matching 'find'.

William

Share this post


Link to post
Share on other sites

MWIDNER21,

Welcome to the AutoIt forum. :x

As kindly recommended by saywell, my RecFileListToArray UDF (link in my sig below) will list files on a path, looking in all the subfolders. You can set masks for the type of file to search for, so you should be able to get an array of the files you need pretty easily.

So, a couple of questions before we start:

- 1. Do the files you are looking for have a unique name/extension? That would make the task really easy as the UDF can filter out all the others.

- 2. If there is nothing unique in the name/extension, how do you determine which files you need to amend?

Once we have these answers we can look to how we get a nice listing of your files so you can do your string replacement magic upon them. :P

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

MWIDNER21,

Welcome to the AutoIt forum. :x

As kindly recommended by saywell, my RecFileListToArray UDF (link in my sig below) will list files on a path, looking in all the subfolders. You can set masks for the type of file to search for, so you should be able to get an array of the files you need pretty easily.

So, a couple of questions before we start:

- 1. Do the files you are looking for have a unique name/extension? That would make the task really easy as the UDF can filter out all the others.

- 2. If there is nothing unique in the name/extension, how do you determine which files you need to amend?

Once we have these answers we can look to how we get a nice listing of your files so you can do your string replacement magic upon them. :P

M23

Thank you for your reply! The extensions of the files I'm trying to find is .txt files and the other portion is a shortcut to launch an app. So that would be .lnk I believe. The txt files are all named the same and I need to change one line inside of them to point to a new server. The names on the shortcut links may not be named exactly the same, but they all are a .lnk.

thank you again for your help.

Edited by MWIDNER21

Share this post


Link to post
Share on other sites

MWIDNER21,

The UDF can easily filter out all just the .txt and .lnk files within all the subfolders on the path - the following line will return them in an array with their full path:

$aArray = _RecFileListToArray("Start_Path", "*.txt;*.lnk", 1, 1, 0, 2)

So all you will have to do is loop through them (the [0] element of the array tells you how many there are) and see if they contain the string you want to replace, which you say you know how to achieve:

I know how to do a replace string within a text file

Over to you! :x

M23

P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :P


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0