renamenote: Rename a note
This commit is contained in:
parent
11490de33b
commit
38e086e8f9
1 changed files with 36 additions and 0 deletions
36
util/renamenote.sh
Normal file
36
util/renamenote.sh
Normal file
|
@ -0,0 +1,36 @@
|
|||
:<<'info'
|
||||
shellnotes - renamenote.sh
|
||||
(C) Dimitris Marakomihelakis
|
||||
Released under the "All rights reserved" category. See the RIGHTS.txt file
|
||||
in /docs/github/ for its full text.
|
||||
info
|
||||
|
||||
function renamenote() {
|
||||
dir="$(pwd)"
|
||||
me="$(whoami)"
|
||||
cd $DEFAULT_PATH
|
||||
if [ $# -eq 0 ]; then
|
||||
echo -n "Enter note name: " && read notename
|
||||
echo -n "Enter new name: " && read newnotename
|
||||
else
|
||||
notename=$1
|
||||
newnotename=$2
|
||||
fi
|
||||
|
||||
if [ -e $notename ]; then
|
||||
if [ -e $newnotename ]; then
|
||||
echo "There is another note named '$newnotename' in your Notes folder."
|
||||
else
|
||||
mv $notename $newnotename
|
||||
clear
|
||||
str="Note renamed from $notename to $newnotename in $DEFAULT_PATH"
|
||||
underlines=$(echo "$str" | tr -c '\010' '-')
|
||||
echo "$str\n$underlines"
|
||||
fi
|
||||
|
||||
else
|
||||
echo "This note does not exist."
|
||||
fi
|
||||
|
||||
cd $dir
|
||||
}
|
Loading…
Reference in a new issue