If you file isn't gigabits in size, why don't you read the whole file into an array.
Then it is easy to remove one line and move it elsewhere.
After that simply rewrite the new file.
VBScript isn't the best language to handle arrays, might I suggest to do it in Javascript instead?
Here something to get you started:
/*********************************************************
* Function move
*
* Move an item from an array from one position to another
*
* Parameters:
* - arr = the array to be modified
* - old_index = current line to be moved
* - new_index = where to move it
********************************************************/
function move(arr, old_index, new_index) {
while (old_index < 0) {
old_index += arr.length;
}
while (new_index < 0) {
new_index += arr.length;
}
if (new_index >= arr.length) {
var k = new_index - arr.length;
while ((k--) + 1) {
arr.push(undefined);
}
}
arr.splice(new_index, 0, arr.splice(old_index, 1)[0]);
return arr;
}
var myFile = Watch.GetJobInfo(1).split("\n");
var theLine = -1;
for(var i = 0; i < myFile.length; i++){
if(myFile[i].search("what you are looking for")>-1){
theLine = i;
break;
}
}
move(myFile,theLine,1);
Watch.SetJobInfo(2,myFile.join("\n"));
Now how to use this in PPWatch? Simple
- ...your process up to this point
- Set Job Infos and Variables plugin where %1 is set to %c
- the script
- Create File plugin with %2 in it.
- rest of your process...
P.S. To not steal glory from someone else, the function's code
move can be found
here