meme-tools

Meme format tools
git clone git://r-36.net/meme-tools
Log | Files | Refs | README | LICENSE

dirrename2meme (721B)


      1 #!/bin/sh
      2 
      3 if [ $# -lt 1 ];
      4 then
      5 	printf "usage: %s file.meme\n" "$(basename "$0")" >&2
      6 	exit 1
      7 fi
      8 
      9 outfile="$1"
     10 
     11 printf "meme\n" > ${outfile}
     12 find . -type f \
     13 | while read -r medianame;
     14 do
     15 	basemedianame="$(basename "${medianame}")"
     16 	newfilename="$(printf "%s" "${basemedianame}" \
     17 		| tr -c 'a-zA-Z0-9.-_' '_')"
     18 	if [ "${basemedianame}" != "${newfilename}" ];
     19 	then
     20 		mv "${medianame}" "${newfilename}"
     21 		printf "%s -> %s\n" "${basemedianame}" "${newfilename}"
     22 	fi
     23 	mpv "${newfilename}"
     24 	printf "%s\n" "${newfilename}"
     25 	memetag="$(thinglaunch -o -p "memetag> ")"
     26 	if [ "${memetag}" = "quit" ];
     27 	then
     28 		exit 0
     29 	fi
     30 
     31 	if [ -n "${memetag}" ];
     32 	then
     33 		printf "#%s %s\n" "${memetag}" "${newfilename}" >> ${outfile}
     34 	fi
     35 done
     36