How to rename a part of a file or files
hey everybody in LQ
I have a few video files with this name structure. TV Show Season 1 - Ep 1 title.mp4 TV Show Season 1 - Ep 2 title.mp4 TV Show Season 1 - Ep 3 title.mp4 etc.. I want to change it to this TV Show Season 1 - Ep 01 title.mp4 TV Show Season 1 - Ep 02 title.mp4 TV Show Season 1 - Ep 03 title.mp4 What is the solution? thank you folks |
How many files are there? Renaming a few can be done by hand...
|
I have 20 files but I want to change the first 9 files. So far I have been doing it manually but it gets tedious after a while.
|
Create a for-in loop over all your *.mp4's
Replace the Ep 1 with Ep 01 etc. Rename it. In a file: Code:
#!/bin/sh Code:
for file in *.mp4; do echo mv \"$file\" \"$(echo $file | sed 's/Ep \([0-9]\)/Ep 0\1/')\" | sh; done |
you're the man parnmatt, it looks like freakin' algebra but it did the job :)
|
You are most welcome.
Programming/Scripting kinda is a bit like maths. Just remember to mark all helpful posts by clicking the Yes in the bottom corner of those posts. And don't forget to mark the thread solved (at the top). |
All times are GMT -5. The time now is 09:46 AM. |