I'm trying to de-organize a series of video files named like this:
Something or Other.s1e1.mp4
Another title.s1e2.mp4
...
Yet More Titles.s1e87.mp4
And so on. What I want to do is strip out the "s1eNUM" part of the filename and restore it back to normal, so I'd get "Something or Other.mp4" and "Yet More Titles.mp4" and such.
Can this be done using Windows command line, with ren and batch files? Or do I need special software? Thanks!!
Use the for command.
This should remove the "s1eNum" in the middle, then combine the file name and the extension at the end.
I'll invent a terminology and say that a node is any text before, after, or between dots. So "Other.s1e1.mp4" would have 3 nodes, the last one being the file extension.
If you know that none of your .mp4 files have more than 3 nodes, than all you need is a simple REN command.
See How does the Windows RENAME command interpret wildcards for an explanation of why this works. Note that you must have enough
?
characters to match or exceed the length of the largest node 1 found.If you may have files that have more than 3 nodes, and you want to remove the penultimate (next to last) node, then 2 nested loops can be used: