-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#576 - created script to make consistent figure names in the assets/i…
…mg directory and in the markdown pages
- Loading branch information
1 parent
7213810
commit da974ab
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
# | ||
# Use as: | ||
# rename_figures.sh <page.md> | ||
# | ||
# 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 |