ycategories-presentation/categories/renameSlideFic.sh

20 lines
433 B
Bash
Raw Normal View History

2012-11-07 13:50:33 +00:00
#!/usr/bin/env zsh
i=10
for fic in *.html; do
title=$( <$fic grep h2 | sed 's/<[^>]*>//g;s/[^a-zA-Z]/_/g;s/__*/_/g;s/^_//;s/_$//')
if ((i<100)); then
num="0$i"
else
num="$i"
fi
((i+=10))
newfic=${num}_$title.${fic:e}
[[ $fic == $newfic ]] && { continue }
[[ -e $newfic ]] && {
print -- "$newfic already exists!" >&2
continue
}
mv $fic $newfic
done