Welcome to the IDM Forum. This forum is meant as a user-to-user support mechanism where users can share knowledge and tips for all IDM software.
Since these forums are user-to-user based, IDM does not regularly read or reply to the posts in this forum. For problem reports, suggestions, or feature requests, you must email us directly. Our trained technical support staff answers most inquiries within 30 minutes.


if (UltraEdit.document.length > 0) {
UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.activeDocument.hexOff();
UltraEdit.perlReOn();
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=true;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=true;
if (UltraEdit.activeDocument.findReplace.find("test='\\d+'")) {
UltraEdit.activeDocument.endSelect();
UltraEdit.activeDocument.key("LEFT ARROW");
UltraEdit.activeDocument.findReplace.searchDown=false;
UltraEdit.activeDocument.findReplace.find("\\d+")
var sNumber = UltraEdit.activeDocument.selection;
var nNumber = parseInt(sNumber,10);
nNumber++;
sNumber = nNumber.toString(10);
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.replaceAll=true;
UltraEdit.activeDocument.findReplace.replaceInAllOpen=false;
UltraEdit.activeDocument.findReplace.selectText=false;
UltraEdit.activeDocument.findReplace.preserveCase=false;
UltraEdit.activeDocument.findReplace.replace("test='\\d+'", "test='"+sNumber+"'");
}
}


UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.perlReOn();
if (GetListOfFiles(0,"???full directory path with \\ for every backslash ???","??? file type ???",false)) {
var nListFile = 0;
var nNumber = 0;
var sNumber = "";
var sFileName = "";
while (nListFile < UltraEdit.document.length) {
if (UltraEdit.document[nListFile].path == UltraEdit.activeDocument.path) break;
nListFile++;
}
while (!UltraEdit.activeDocument.isEof()) {
UltraEdit.activeDocument.startSelect();
UltraEdit.activeDocument.key("END");
sFileName = UltraEdit.activeDocument.selection;
UltraEdit.activeDocument.endSelect();
UltraEdit.activeDocument.key("HOME");
UltraEdit.activeDocument.key("DOWN ARROW");
UltraEdit.open(sFileName);
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=true;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=true;
if (UltraEdit.activeDocument.findReplace.find("test='\\d+'")) {
UltraEdit.activeDocument.endSelect();
UltraEdit.activeDocument.key("LEFT ARROW");
UltraEdit.activeDocument.findReplace.searchDown=false;
UltraEdit.activeDocument.findReplace.find("\\d+")
sNumber = UltraEdit.activeDocument.selection;
nNumber = parseInt(sNumber,10);
nNumber++;
sNumber = nNumber.toString(10);
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.replaceAll=true;
UltraEdit.activeDocument.findReplace.replaceInAllOpen=false;
UltraEdit.activeDocument.findReplace.selectText=false;
UltraEdit.activeDocument.findReplace.preserveCase=false;
UltraEdit.activeDocument.findReplace.replace("test='\\d+'", "test='"+sNumber+"'");
UltraEdit.closeFile(UltraEdit.activeDocument.path,1);
}
else UltraEdit.closeFile(UltraEdit.activeDocument.path,2);
UltraEdit.document[nListFile].setActive();
}
UltraEdit.closeFile(UltraEdit.activeDocument.path,2);
}


UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.perlReOn();
var nXmlFile = 0;
var nListFile = 0;
var sSplit = "";
var sFileName = "";
var sTitle = "";
var sDocLvl = "";
UltraEdit.activeDocument.top();
while (nListFile < UltraEdit.document.length) {
if (UltraEdit.document[nListFile].path == UltraEdit.activeDocument.path) break;
nListFile++;
}
while (!UltraEdit.activeDocument.isEof()) {
// Select everything from the beginning of the line to the end of the line.
UltraEdit.activeDocument.startSelect();
UltraEdit.activeDocument.key("END");
sSplit = UltraEdit.activeDocument.selection;
UltraEdit.activeDocument.endSelect();
UltraEdit.activeDocument.key("HOME");
UltraEdit.activeDocument.key("DOWN ARROW");
/* I need to slice this string into 3 parameters using the comma as the
parameter indicator.
param 1 = sFileName;
param 2 = sTitle;
param 3 = sDocLvl;
*/
var sTocArray = sSplit.split(',');
sFileName = sDocArray[0];
sTitle = sDocArray[1];
sDocLvl = sDocArray[2];
for (nXmlFile = 0; nXmlFile < UltraEdit.document.length; nXmlFile++) {
if (UltraEdit.document[nXmlFile].path == sFileName) break;
}
if (nXmlFile < UltraEdit.document.length) UltraEdit.document[nXmlFile].setActive();
else UltraEdit.open(sFileName);
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=true;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=true;
if (UltraEdit.activeDocument.findReplace.find(sTitle)) {
UltraEdit.activeDocument.endSelect();
UltraEdit.activeDocument.key("LEFT ARROW");
UltraEdit.activeDocument.findReplace.searchDown=false;
UltraEdit.activeDocument.findReplace.find("level='\\d+'");
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.replaceAll=false;
UltraEdit.activeDocument.findReplace.replaceInAllOpen=false;
UltraEdit.activeDocument.findReplace.selectText=false;
UltraEdit.activeDocument.findReplace.preserveCase=false;
UltraEdit.activeDocument.findReplace.replace("level ='\\d+'", sDocLvl);
UltraEdit.closeFile(UltraEdit.activeDocument.path,1);
}
else UltraEdit.closeFile(UltraEdit.activeDocument.path,2);
UltraEdit.document[nListFile].setActive();
}test.xml,title='asdfawefaw', level ='3'
test1.xml,title='test test test', level ='9'
test2.xml,title='test test5 test', level ='3'
test3.xml,title='test test test', level ='5'
test4.xml,title='test4 test test', level ='2'title='test test test' level ='4'
title='test test5 test' level ='1'
title='test test test', level ='2'


UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.perlReOn();
var nXmlFile = 0;
var nListFile = 0;
var sSplit = "";
var sFileName = "";
var sTitle = "";
var sTocLvl = "";
UltraEdit.activeDocument.top();
while (nListFile < UltraEdit.document.length) {
if (UltraEdit.document[nListFile].path == UltraEdit.activeDocument.path) break;
nListFile++;
}
while (!UltraEdit.activeDocument.isEof()) {
// Select everything from the beginning of the line to the end of the line.
UltraEdit.activeDocument.startSelect();
UltraEdit.activeDocument.key("END");
sSplit = UltraEdit.activeDocument.selection;
UltraEdit.activeDocument.endSelect();
UltraEdit.activeDocument.key("HOME");
UltraEdit.activeDocument.key("DOWN ARROW");
/* I need to slice this string into 3 parameters using the comma as the
parameter indicator.
param 1 = sFileName;
param 2 = sTitle;
param 3 = sTocLvl;
*/
var sTocArray = sSplit.split(',');
sFileName = sTocArray[0];
sTitle = sTocArray[1];
sTocLvl = sTocArray[2];
for (nXmlFile = 0; nXmlFile < UltraEdit.document.length; nXmlFile++) {
if (UltraEdit.document[nXmlFile].path == sFileName) break;
}
if (nXmlFile < UltraEdit.document.length) UltraEdit.document[nXmlFile].setActive();
else UltraEdit.open(sFileName);
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=true;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=true;
if (UltraEdit.activeDocument.findReplace.find(title='.*?')) {
UltraEdit.activeDocument.endSelect();
UltraEdit.activeDocument.findReplace.replace("title='.*?'", sTitle);
UltraEdit.activeDocument.key("LEFT ARROW");
UltraEdit.activeDocument.findReplace.searchDown=false;
UltraEdit.activeDocument.findReplace.find("toclevel='\\d+'");
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.replaceAll=false;
UltraEdit.activeDocument.findReplace.replaceInAllOpen=false;
UltraEdit.activeDocument.findReplace.selectText=false;
UltraEdit.activeDocument.findReplace.preserveCase=false;
UltraEdit.activeDocument.findReplace.replace("toclevel ='\\d+'", sTocLvl);
UltraEdit.closeFile(UltraEdit.activeDocument.path,1);
}
else UltraEdit.closeFile(UltraEdit.activeDocument.path,2);
UltraEdit.document[nListFile].setActive();
}C:\GAMES\TEST.xml,title='Game to Space',toclevel='3'
C:\GAMES\TEST2.xml,title='Gamers System',toclevel='2'
C:\GAMES\TEST3.xml,title='Identify Game Creation',toclevel='4'title='test test test' level ='4'
title='test test5 test' level ='7'
title='test test test', level ='9'

UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.perlReOn();
var nXmlFile = 0;
var nListFile = 0;
var sSplit = "";
var sFileName = "";
var sTitle = "";
var sTocLvl = "";
var sLowerCaseFileName = "";
UltraEdit.activeDocument.top();
while (nListFile < UltraEdit.document.length) {
if (UltraEdit.document[nListFile].path == UltraEdit.activeDocument.path) break;
nListFile++;
}
while (!UltraEdit.activeDocument.isEof()) {
// Select everything from the beginning of the line to the end of the line.
UltraEdit.activeDocument.startSelect();
UltraEdit.activeDocument.key("END");
sSplit = UltraEdit.activeDocument.selection;
UltraEdit.activeDocument.endSelect();
UltraEdit.activeDocument.key("HOME");
UltraEdit.activeDocument.key("DOWN ARROW");
/* I need to slice this string into 3 parameters using the comma as the
parameter indicator.
param 1 = sFileName;
param 2 = sTitle;
param 3 = sTocLvl;
*/
var sTocArray = sSplit.split(',');
sFileName = sTocArray[0];
sTitle = sTocArray[1];
sTocLvl = sTocArray[2];
sLowerCaseFileName = sFileName.toLowerCase();
for (nXmlFile = 0; nXmlFile < UltraEdit.document.length; nXmlFile++) {
// String compares are case sensitive. Therefore better make always
// both file names lowercase and then compare the file names.
if (UltraEdit.document[nXmlFile].path.toLowerCase() == sLowerCaseFileName) break;
}
if (nXmlFile < UltraEdit.document.length) UltraEdit.document[nXmlFile].setActive();
else UltraEdit.open(sFileName);
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=true;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.regExp=true;
if (UltraEdit.activeDocument.findReplace.find("title='.*?'")) {
UltraEdit.activeDocument.write(sTitle);
if (UltraEdit.activeDocument.findReplace.find("level ='\\d+'")) {
UltraEdit.activeDocument.write(sTocLvl);
}
// If the XML file was already open and it was in the file tab sequence
// left the list file, the document number of the list file would change
// when closing now the XML file. So better just save the XML file in this
// case and let the file open.
if (nXmlFile > nListFile) UltraEdit.closeFile(UltraEdit.activeDocument.path,1);
else UltraEdit.save();
}
else {
if (nXmlFile > nListFile) UltraEdit.closeFile(UltraEdit.activeDocument.path,2);
}
UltraEdit.document[nListFile].setActive();
}
for (nXmlFile = 0; nXmlFile < UltraEdit.document.length; nXmlFile++) {
if (UltraEdit.document[nXmlFile].path === sFilePath) break;
}
if (nXmlFile < UltraEdit.document.length) UltraEdit.document[nXmlFile].setActive();
else UltraEdit.newFile();

sLowerCaseFileName = sFileName.toLowerCase();
// Scan in the array of opened files if the next file from the list is already opened in UE / UES.
for (nXmlFile = 0; nXmlFile < UltraEdit.document.length; nXmlFile++) {
// String compares are case sensitive. Therefore better make always both file names lowercase
// and then compare the file names. For example the list file could contain TEST.xml, but the
// real file name is Test.xml and Test.xml is already open. When just comparing the file names
// case sensitive without making both lowercase, "TEST.xml" is different "Test.xml" and this
// loop would therefore not detect that the file Test.xml is already open. For Linux that
// would be correct, but not for Windows because Windows file systems are not case sensitive.
if (UltraEdit.document[nXmlFile].path.toLowerCase() == sLowerCaseFileName) break;
}
// If the loop variable is smaller the number of opened files, the file to open next
// is already opened and therefore this file must just be set the active file. Otherwise
// the file must be opened and becomes then automatically the active file. This is a
// different behavior in opening a file from within a script in comparison to opening
// a file manually. When manually opening a file which is already open, UltraEdit does
// not load it (and discards all modifications), it just makes the file active. But
// opening a file from within a script which is already opened does not make the file
// active. Therefore this code is necessary to continue the script on the correct file
// when one or more files from the list file are already opened in UltraEdit / UEStudio.
if (nXmlFile < UltraEdit.document.length) UltraEdit.document[nXmlFile].setActive();
else UltraEdit.open(sFileName);


<p>5</p>
<p>text</p>
<p>6</p>
<p>text</p>
<p>7</p>
<p>text</p>
<p>8</p>if (UltraEdit.document.length > 0) {
UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.activeDocument.hexOff();
UltraEdit.perlReOn();
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.findReplace.mode=0;
UltraEdit.activeDocument.findReplace.matchCase=false;
UltraEdit.activeDocument.findReplace.matchWord=false;
UltraEdit.activeDocument.findReplace.searchDown=true;
UltraEdit.activeDocument.findReplace.regExp=true;
while (UltraEdit.activeDocument.findReplace.find("(?<=<p>)\\d+(?=</p>)")) {
var sNumber = UltraEdit.activeDocument.selection;
var nNumber = parseInt(sNumber,10);
nNumber++;
UltraEdit.activeDocument.write(nNumber.toString(10));
}
UltraEdit.activeDocument.top();
}