From da974abcfaa0efe9917d4e6e068a8bca2fc46402 Mon Sep 17 00:00:00 2001 From: Robert Oostenveld Date: Fri, 15 Jul 2022 09:32:50 +0200 Subject: [PATCH] #576 - created script to make consistent figure names in the assets/img directory and in the markdown pages --- _scripts/rename_figures.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 _scripts/rename_figures.sh diff --git a/_scripts/rename_figures.sh b/_scripts/rename_figures.sh new file mode 100755 index 000000000..81ad98be6 --- /dev/null +++ b/_scripts/rename_figures.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Use as: +# rename_figures.sh +# +# This script does not do the conversion itself, but prints the commands to screen. +# The user of the script shoudl check teh commands prior to execution + +[ -e "$1" ] || exit 1 + +figures=$(grep "include image" $1 | cut -d \" -f 2) + +echo $figures + +n=1 +for figure in $figures ; do + oldname=$(basename $figure) + ext=$(echo $oldname | cut -f 2 -d '.') + newname=$(dirname $figure)/figure"$n"."$ext" + echo git mv ."$figure" ."$newname" + echo sed -i .bak s~$figure~$newname~g $1 + n=$(expr $n + 1) +done