Search & replace macro from a list of file names

Help with writing and playing macros

Search & replace macro from a list of file names

Postby rscof » Fri Dec 08, 2006 11:15 pm

I'm sure UE is capable of this...but it escapes me?

I have a file named list.txt which has list file names in it. I want to create a macro that reads in this list of file names from a specified directory (not in the list.txt file) search and replace text in each of the files and save them off in a directory other than the source. It would also be nice not to modify the time stamp.

Can UE perform a list of commands on a set of files within a list?

Thanks for the help!
Rick
User avatar
rscof
Newbie
 
Posts: 2
Joined: Tue Nov 07, 2006 12:00 am

Re: Search & replace macro from a list of file names

Postby Mofi » Sat Dec 09, 2006 11:59 am

Yes, that can be done with a macro except not modifying the time stamp.

But before talking about the most complicated method you want, let's talk about a more easier solution.

You could simply copy the files with a batch file to the new directory and then use the UltraEdit command line parameters /flistfile (or wildcards like *.c) and /M,E="macro file/macro name" to open all the files at the new location with a list file which contains all the files with full name and runs a macro with 1 or more Replace All AllFiles and SaveAll to make the modifications.

The complicated solution you want must be something like that (developed directly here - not tested):

InsertMode
ColumnModeOff
HexOff
Open "name of your list file with full path"
Bottom
IfColNumGt 1
"
"
EndIf
Top
TrimTrailingSpaces
Clipboard 9
Loop
IfEof
ExitLoop
EndIf
StartSelect
Key END
Copy
EndSelect
Key HOME
Key DOWN ARROW
Open "source path\^c"
Here are your replaces!
SaveAs "target path\^c"
CloseFile
EndLoop
CloseFile NoSave
ClearClipboard
Clipboard 0

Depending on your version of UltraEdit and your settings make sure the list file is the most right file in the open file tabs order or better the only file permanently open. See Problem with Previous Window/Tab Command why this is important.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4058
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Macros