Locodarwin Posted May 15, 2006 Share Posted May 15, 2006 I've created a very simple and yet very handy bulk filename search & replace tool. Similar ones likely exist; I did a quick search but could not find anything that performed this exact function. Given a folder name (which can be browsed to), the tool will search out any filenames in the folder that contain the 'search' text and replace said text with the contents of the 'replace' input control. For example, if you have a directory with 20 files all named "john1.txt" through "john20.txt" that you want to change to "jane1.txt" through "jane20.txt", just use the search phrase of 'john' and a replace phrase of 'jane' and point to the correct directory. Saves a bunch of time for those who deal with lots of little report files, logs, etc. It can change the names of hundreds of files in mere seconds.Filename_S_R.au3 (Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent] Link to comment Share on other sites More sharing options...
Locodarwin Posted May 15, 2006 Author Share Posted May 15, 2006 (edited) And here's a function to perform the same thing: #include <Array.au3> Func _FilenameSearchReplace($FSR_folder, $FSR_searchphrase, $FSR_replacephrase) $FSR_filelist = _FileListToArray($FSR_folder) Dim $FSR_outputlist[$FSR_filelist[0] + 1] For $FSR_x = 1 to $FSR_filelist[0] Local $in = $FSR_folder & "\" & $FSR_filelist[$FSR_x] Local $out = StringReplace($FSR_filelist[$FSR_x], $FSR_searchphrase, $FSR_replacephrase) $FSR_outputlist[$FSR_x] = $FSR_folder & "\" & $out FileMove($in, $FSR_outputlist[$FSR_x]) Next EndFunc Edited May 15, 2006 by Locodarwin (Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now