dotfiles

<-- duh.
git clone https://hhvn.uk/dotfiles
git clone git://hhvn.uk/dotfiles
Log | Files | Refs | Submodules | LICENSE

convf (982B)


      1 #!/bin/sh
      2 
      3 [ "$(echo "$1" | grep "help")" != "" ] && printf "
      4 	convf [conversion function] [options to function]
      5 
      6 $(tput bold)CONVERSION FUNCTIONS$(tput sgr0)
      7 	convert
      8 	ffmpeg\n" && exit
      9 
     10 count=0
     11 getfiles() {
     12         files="$files $(ls | awk "/$1/ {print}")"
     13 }
     14 _convert(){
     15 	convert $1 $opts $1
     16 	touch $f/$count2
     17 }
     18 _ffmpeg(){
     19 	ffmpeg -i $1 $opts $1
     20 	touch $f/$count2
     21 }
     22 
     23 opts=$(echo "$@" | sed 's/^[[:space:]]*[a-z]*//')
     24 case "$1" in
     25 	convert) filetypes="png jpg jpeg jpe tif"; func="_convert" ;;
     26 	ffmpeg) filetypes="mkv opus mp4 mp3 m4a webm"; func="_ffmpeg" ;;
     27 	*) echo "$1: not supported."; exit ;;
     28 esac
     29 
     30 total=$(ls $dir | wc -l)
     31 f=$(mktemp -d)
     32 for filetype in $filetypes
     33 do
     34 	getfiles $filetype
     35 done
     36 
     37 count2=0
     38 for file in $files
     39 do
     40 	count2=$(($count2+1))
     41 	$func $file &
     42 done
     43 
     44 while true
     45 do
     46 	sleep 0.1
     47 	[ "$(ls $f)" = "" ] && break
     48 	count=$(find $f | wc -l)
     49 	count=$(($count-$total))
     50 	count=$(echo "$count" | sed 's/^[[:space:]]*-//')
     51 	clear
     52 	echo "[$count/$total]"
     53 done
     54 
     55 rm -rf $f