LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   trying to change part of text with sequence for filename (https://www.linuxquestions.org/questions/linux-newbie-8/trying-to-change-part-of-text-with-sequence-for-filename-4175444350/)

Adol 01-06-2013 06:42 AM

trying to change part of text with sequence for filename
 
Hello,

I have many files from when I made my tv show collection, but the way I made it is not compatible with the program Im using to get information for it.

For example I saved it as:
Code:

NameOfShow Episode 01 NameOfEpisode
I want to change Episode 01 to 1x1.

The problem is that I have many shows(MASH) and changing them one by one will take way too long.

I could change them easily using Dolphin but then I loose the Name of Episode.

How can I change the name while keeping NameOfShow and NameOfEpisode and have it automaticaly count up(1x1,1x2,1x3,etc)?

allend 01-06-2013 07:55 AM

This should work for episodes 1 to 9 if run in a bash shell in the directory containing the files
Code:

for file in *; do echo "${file/Episode 0/1x}"; done
After checking, replace 'echo' with 'mv "$file"'.

It is left as an exercise to adjust this for more than 9 episodes.

Adol 01-09-2013 06:20 AM

Quote:

Originally Posted by allend (Post 4863891)
This should work for episodes 1 to 9 if run in a bash shell in the directory containing the files
Code:

for file in *; do echo "${file/Episode 0/1x}"; done
After checking, replace 'echo' with 'mv "$file"'.

It is left as an exercise to adjust this for more than 9 episodes.

Thank you very much and sorry for the late reply.

Im going to try this out over the weekend.

Thank you.

David the H. 01-09-2013 04:32 PM

Hello neighbor!

Try doing a forum search. There have been many, many, many previous threads about how to bulk rename files.

Adol 01-12-2013 06:10 AM

Quote:

Originally Posted by David the H. (Post 4866494)
Hello neighbor!

Try doing a forum search. There have been many, many, many previous threads about how to bulk rename files.

Sorry about that.

The problem with search is that many time I don’t know what to search for.

I`ll try to search more in the future.

Nice to see another forum member in Osaka.

shivaa 01-12-2013 07:02 AM

@Adol,
Can you share some sample entries of file that containing show/episodes list and sample output that you want?
Actually, I had tried it using a script, but without sample data it's not easy to suggest any solution.

schneidz 01-13-2013 11:02 AM

this has to be modified for each season:
Code:

i=01; while [ $i -le 13 ]; do ln -s frisky-dingo-$i-* frisky-dingo.1$i.mkv; i=`expr $i + 1 | awk '{printf "%.2d", $1}'`; done # season 1 scraping
x=01; while [ $i -le 25 ]; do ln -s frisky-dingo-$i-* frisky-dingo.2$x.mkv; x=`expr $x + 1 | awk '{printf "%.2d", $1}'`; i=`expr $i + 1`; done # season 2 scraping

this worx for me on xbmc. you can probably use the mv command instead of creating soft-links. you would need to use something like awk to parse the part of the filename (episode name) in the resultant filename.


All times are GMT -5. The time now is 10:39 PM.