Search & replace macro from a list of file names

Search & replace macro from a list of file names

2
NewbieNewbie
2

    Dec 09, 2006#1

    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

    6,603548
    Grand MasterGrand Master
    6,603548

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

      Dec 09, 2006#2

      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.
      Best regards from an UC/UE/UES for Windows user from Austria