Hi,
I am very new to UltraEdit, but am liking what I see. Is there an easy way to add the filename (no path neccesary) to the beginning of each line within a file, across many files? I am using ultraedit ver 16.
Thanks
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.
var doc = UltraEdit.activeDocument,
lineTerm = doc.lineTerminator === 1 ? '\n' : doc.lineTerminator === 2 ? '\r' : '\r\n',
fLines = [],
fName = '';
doc.selectAll();
fLines = doc.selection.split(lineTerm);
doc.bottom();
doc.top();
fName = doc.path.replace(/.+\\/,'');
UltraEdit.newFile();
for (var i = 0; i < fLines.length;i++) {
doc.write(fName + ' ' + fLines[i] + lineTerm);
}if (UltraEdit.document.length > 0) {
UltraEdit.insertMode();
UltraEdit.columnModeOn();
for (var nDocIndex = 0; nDocIndex < UltraEdit.document.length; nDocIndex++) {
// Ignore files opened in hex edit mode.
if (UltraEdit.document[nDocIndex].isHexModeOn()) continue;
// Get name of the file with a simplified method. Better method working
// also for FTP loaded files and for UNIX file paths offers the function
// GetNameOfFile() in http://www.ultraedit.com/files/scripts/FileNameFunctions.js
var nLastBackslashPos = UltraEdit.document[nDocIndex].path.lastIndexOf('\\');
// Ignore not saved new files.
if (nLastBackslashPos < 0) continue;
var sFileName = UltraEdit.document[nDocIndex].path.substr(++nLastBackslashPos);
UltraEdit.document[nDocIndex].top();
// Insert in column mode the file name at beginning of every line.
UltraEdit.document[nDocIndex].columnInsert(sFileName + ": ");
}
UltraEdit.columnModeOff();
}