[Bash/Linux] Help with Rename script

Come up with a useful post-processing script? Share it here!
Post Reply
dashy
Newbie
Newbie
Posts: 13
Joined: August 16th, 2011, 10:46 am

[Bash/Linux] Help with Rename script

Post by dashy »

Hi all,

Newb here - I'm looking for help coding an automatic renamer script which will remove the source/codec/group from commonly downloaded tv files. For example, I'd like the script to change:
minute.to.win.it.s02e38.hdtv.xvid-qcf.avi TO minute.to.win.it.s02e38.avi
House.S07E22.HDTV.x264-DIMENSION.mkv TO House.S07E22.mkv

Basically this applies only to TV shows so all I want it to search for "hdtv", and remove that until the period before the file extension. Any tips? Thanks in advance!
User avatar
Mar2zz
Jr. Member
Jr. Member
Posts: 85
Joined: February 4th, 2011, 8:30 am
Contact:

Re: [Bash/Linux] Help with Rename script

Post by Mar2zz »

Use sed to replace stuff.

pseudocode:
#$1 is inputfile (or directory)

filename=$(basename $1)
extension=${filename##*.}
newname=echo $filename | sed 's/.xvid.*\|.x264.*//g'
mv $filename $newname.$extension
dashy
Newbie
Newbie
Posts: 13
Joined: August 16th, 2011, 10:46 am

Re: [Bash/Linux] Help with Rename script

Post by dashy »

Thanks for your help :)
Post Reply