Batch delete a RANGE OF LINES in multiple files?
-
I am editing files in Poser Pro 11. They are text files that define the location and poses of rigged 3D objects. This is irrelevant info, but I provide it in case someone asks thinking that the language somehow matters to the task at hand.
I have a range of text that I would like to delete from 50+ files.
The text starts on line 10 and ends on line 57.In each of those files, I want to delete that range. Please note:
- Although the opening is unique, the closing is not (there are LOTS of quadruple closing brackets in this file).
- Rather than figure out some workaround about searching for a string of info (that occasionally changes: sometimes there is an extra space in there after a number or bracket), I would rather just delete the range of lines.
Is this possible?
If not, I am open to other suggestions. But please be mindful – the closing range is not unique.Sample of the text (copied from Notepad++)
actor hip:1
{
channels
{
rotateY yrot
{
keys
{
k 0 -110
}
}
rotateZ zrot
{
keys
{
k 0 -0
}
}
rotateX xrot
{
keys
{
k 0 -5
}
}
translateX xtran
{
keys
{
k 0 0
}
}
translateY ytran
{
keys
{
k 0 -0.00400003
}
}
translateZ ztran
{
keys
{
k 0 0
}
}
}
} -
Here’s a technique you might try (try it on ONE file, first, of course, and have backups of your data at all times!)
.
Find:(?s)(?<!\x0A)^((?:.*?\R){9})(?:.*?\R){48}
Replace:\1
Search mode: Regular expressionWhat this does is match the first 57 lines, but it captures only the first 9 lines. Then it replaces the whole first-57-line blob with what was captured (i.e., the first 9 lines). Thus, effectively lines 10-57 get removed.
You may have to tweak the numbers in the find expression a bit, I tried it out on something much smaller.
-
You have effectively blown my mind!
I’ll try it this evening and let you know if it works.
Thank you very much! -
Well…let’s see how it goes on your data…
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login