我想編寫一個腳本來打開資料夾中的許多jsl檔案。在每個 jsl 檔案中,我需要找到一個文字並將其替換為另一個文字。儲存每個檔案並關閉它,然後再繼續處理資料夾中的下一個檔案。我嘗試使用“替代”,但沒有成功。感謝所有的幫助!
//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
考慮使用
載入文字檔()
和
儲存文字檔()
而不是使用 Open()。
Load Text File() 會將完整檔案放入單一文字字串變數中,然後您可以使用 Substitute() 取代該字串,然後使用 Save Text File 將其儲存回來。