Open all jsl files in a folder, find and replace text, save and close filesI want to write a script to open many jsl files in a folder. In each jsl file, I need to find a text and replace it with another text. Save each file and close it before going onto the next file in the folder. I tried to use "substitute" but did not work. Appreciate all the help!
//folder contains 224 jsl scripts
folderID = "T:\JMP_SCRIPTS\Openfiles n update\test\";
Files = Files In Directory(FolderID);
For(i = 1, i <= N Items(Files), i++,
FileID = Files[i];
//Open jsl file
openFile = Open(folderID || FileID);
subdt = Substitute(openFile, "99@wefghynKm0r3", "hihi");
openFile << Save(folderID || FileID);
Close(openFile, No Save);
);// End FOR loop
Automation and ScriptingRe: Open all jsl files in a folder, find and replace text, save and close filesFacinating, thanks! It works for me!
Re: Open all jsl files in a folder, find and replace text, save and close filesLook into using
Load Text File()
and
Save Text File()
rather than using Open().
Load Text File() will bring the complete file into a single literal string variable and you will then be able to use Substitute() for the string and then save it back using the Save Text File.