XML Convert to CR/LFs - Batch?

Help with writing and running scripts

XML Convert to CR/LFs - Batch?

Postby saxamo » Sat Sep 29, 2012 9:06 am

Hello there,

Is there any way for me to convert multiple files from their current format to CR/LFs without having to do it one by one? My output folders have about 140 xml documents in them each time i run the script. I then have to go in and convert to CR/LFs in order to find the field I am looking for. Is there any script or option in Ultraedit that I can run on a folder that would automatically do the XML Convert for me for all the items in the folder I choose, rather then me doing them one at a time? Any help or advice is appreciated. Thanks
saxamo
Newbie
 
Posts: 2
Joined: Sat Sep 29, 2012 9:01 am

Re: XML Convert to CR/LFs - Batch?

Postby Mofi » Sat Sep 29, 2012 10:55 am

If you are using English UltraEdit and have not modified the Find Output Format configuration settings, you can

  • download GetListOfFiles.js,
  • open this UltraEdit script in UltraEdit,
  • replace the last line in this file by

    Code: Select all
    if (GetListOfFiles(nSearchIn,sFolder,sFiles,bSubFolders)) {
       UltraEdit.activeDocument.selectAll();
       var asFileNames = UltraEdit.activeDocument.selection.split("\r\n");
       asFileNames.pop();  // Remove empty string at end of array of file names.
       UltraEdit.closeFile(UltraEdit.activeDocument.path,2);
       UltraEdit.outputWindow.write("\nFound "+asFileNames.length+"file"+((asFileNames.length != 1) ? "s:\n" : ":\n"));
       for (nFile = 0; nFile < asFileNames.length; nFile++) {
          UltraEdit.open(asFileNames[nFile]);
          UltraEdit.activeDocument.xmlConvertToCRLF();
          UltraEdit.closeFile(UltraEdit.activeDocument.path,1);
          UltraEdit.outputWindow.write(asFileNames[nFile]);
       }
    }

  • save the script file,
  • execute it using Scripting - Run Active Script and
  • enter the data for getting the list of XML file names to open, convert, save and close.
You need to adapt 2 string variables according to comments at top of the script if you are using UltraEdit in a different language or with having Find Summary definition string changed or disabled.

Note: None of the XML files to convert should be opened already in UltraEdit as this would result in failing of the script.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3937
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: XML Convert to CR/LFs - Batch?

Postby saxamo » Sat Sep 29, 2012 11:42 am

Worked Perfectly... Thanks so much.. Wish this was an option in UltraEdit, but this worked perfectly.. I mean.. wow.. amazing.. you did it.. Thank you!!!
saxamo
Newbie
 
Posts: 2
Joined: Sat Sep 29, 2012 9:01 am


Return to Scripts