0

I have a folder contains many .ass files for subtitles of a TV show but the file name is just too long:

House.of.Cards.S01E01.WEBRip.720p.H.264.AAC.2.0-HoC.SOME-OTHER-THINGS.ass House.of.Cards.S01E02.WEBRip.720p.H.264.AAC.2.0-HoC.SOME-OTHER-THINGS.ass House.of.Cards.S01E03.WEBRip.720p.H.264.AAC.2.0-HoC.SOME-OTHER-THINGS.ass

now I just want to change them into shorter form:

House.of.Cards.S01E01.ass
House.of.Cards.S01E02.ass
House.of.Cards.S01E03.ass

is there any simple way to do it? (may be via shell script)

Thanks in advance

hihell
  • 936
  • 1
  • 10
  • 20

1 Answers1

0

there is a (not so) simple way to do it

for f in *; do mv "$f" "${f//.H.*/}"; done
for f in *; do mv "$f" "$f.ass"; done
hihell
  • 936
  • 1
  • 10
  • 20
  • 1
    yeah, was just about to recommend reading up here, but you found it already it seems: http://tldp.org/LDP/abs/html/string-manipulation.html – JP Lew Sep 04 '13 at 08:17