diff options
-rwxr-xr-x | 20210525_082840 | 2 | ||||
-rwxr-xr-x | bin/add-new.sh | 9 | ||||
-rwxr-xr-x | bin/migrate.sh | 13 |
3 files changed, 21 insertions, 3 deletions
diff --git a/20210525_082840 b/20210525_082840 index 61dfd16..4c01117 100755 --- a/20210525_082840 +++ b/20210525_082840 @@ -1,4 +1,4 @@ -[NEWS] Created script to quickly add news to the repo +Created script to quickly add news to the repo I only use timestamp for file name. I open an editor for that and from there, the first line is the title as happens most of the times. diff --git a/bin/add-new.sh b/bin/add-new.sh index c82bc70..086cff8 100755 --- a/bin/add-new.sh +++ b/bin/add-new.sh @@ -1,5 +1,10 @@ #!/bin/bash export NEWS_FILE="$(date +%Y%m%d_%H%M%S)" vi $NEWS_FILE -git add $NEWS_FILE -git commit -m "$(head -n 1 $NEWS_FILE)" +echo "Renaming..." +TITLE="$(head -n 1 $NEWS_FILE)" +TO_FILE=$NEWS_FILE-$(echo $TITLE | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g' ) +mv $NEWS_FILE $TO_FILE +echo "Adding to git repo..." +git add $TO_FILE +git commit -m "Added $NEWS_FILE with $(head -n 1 $TO_FILE)" diff --git a/bin/migrate.sh b/bin/migrate.sh new file mode 100755 index 0000000..8b6db20 --- /dev/null +++ b/bin/migrate.sh @@ -0,0 +1,13 @@ +#!/bin/bash +echo "Migration tool: please run only once" +FILES=$(ls -1 | grep 202) +for file in $FILES; do + if [ -f $file ] + then + title="$(head -n 1 $file)" + new_name="$file-$(echo "$title" | tr '[:upper:]' '[:lower:]' | sed -e 's/ /\_/g')" + mv $file $new_name + git add $file $new_name + git commit -m "Migrated to new naming $file to $new_name"; + fi +done |