Sorry if this has been asked before, I tried to search and didn’t find anything specific to this.
Our software vendor currently sends our print server (which creates the txt files) data with 6 spaces at the beginning of each line. In a few weeks they are changing to 3 spaces. Is there an easy way to deal with this without changing all the data mapping and workflow? Is there another step I can add right after folder capture to add the extra 3 spaces? Version 2021.2.1.3151
The most efficient way is to use a script immediately after your Folder Capture task. The following JavaScript code shows how to remove 3 characters from each line (it also shows how to add 3 blank spaces to each line, if that’s what you actually need).
var fileName = Watch.GetJobFileName();
var fso = new ActiveXObject("SCripting.FileSystemObject");
var inFile = fso.OpenTextFile(fileName,1);
var outFile = fso.CreateTextFile(fileName+".txt");
while(!inFile.AtEndOfStream){
// remove 3 characters
outFile.WriteLine(inFile.ReadLine().substring(3));
// add 3 blanks
// outFile.WriteLine(" "+inFile.ReadLine());
}
inFile.Close();
outFile.Close();
fso.CopyFile(fileName+".txt", fileName, true);