Scriptek na rename seriálů

From Pitrissek, 6 Years ago, written in Bash, viewed 103 times.
URL https://pastebin.chytrex.cz/view/0b02e092 Embed
Download Paste or View Raw
  1. #!/bin/bash
  2. FAJL="$1"
  3. if [ -z "$FAJL" ]; then
  4.         echo "Parametr neuveden, predpokladam *.avi";echo
  5.         FAJL="*.avi"
  6. fi
  7. EXT=${FAJL##*.}
  8.  
  9. ls -1 $FAJL | sort -n > /tmp/series-ren.tmp
  10.  
  11. if [ -r names.txt ]; then
  12.         if [ "$(wc -l <names.txt)" -ne "$(wc -l </tmp/series-ren.tmp)" ]; then
  13.                 echo "Pocet souboru v names.txt nesouhlasi s poctem souboru odpovidajicim $FAJL."
  14.                 exit 1
  15.         fi
  16.  
  17.         iconv -f "UTF-8" -t "ascii//TRANSLIT" "names.txt" | sed 's/ /-/g;s/ /-/g' > "/tmp/series-ren.names"
  18.         cat /dev/null > redo.log
  19.  
  20.         while read -r FILENAME && read -r NEWNAME <&3; do
  21.                 read NUMB FNAME <<< $NEWNAME
  22.                 NEWNAME=${NUMB}_${FNAME}
  23.                 echo "$FILENAME $NEWNAME" >> redo.log
  24.                 mv "$FILENAME" "$NEWNAME.$EXT"
  25.         done </tmp/series-ren.tmp 3</tmp/series-ren.names
  26. else
  27.         echo "Nenalezen names.txt, nemam co delat!"
  28.         exit 1
  29. fi

Reply to "Scriptek na rename seriálů"

Here you can reply to the paste above