...
 
Commits (5)
......@@ -23,10 +23,11 @@ check_bash_version
build_usable_basename() {
local hsh=$(sha1sum "$fn" | cut -c 1-8 | tr '[:upper:]' '[:lower:]')
local fn="$1"
local hsh=$(/usr/local/bin/sha1sum "$fn" | cut -c 1-8 | tr '[:upper:]' '[:lower:]')
local bn=$(basename "$fn")
echo "${bn%.*}-$hsh.${bn##*.}" | tr ' ' '-'
echo "${bn%.*}-${hsh}.${bn##*.}" | tr ' ' '-'
}
......@@ -34,6 +35,10 @@ copy_attachments_to_vault() {
for orig_fn in "${!attachments_list[@]}"; do
local new_bn="${attachments_list["$orig_fn"]}"
if [ ! -d "$target_folder_attachments" ]; then
mkdir -p "$target_folder_attachments"
fi
echo "Copying attachment '$orig_fn' to '$target_folder_attachments/$new_bn'"
cp "$orig_fn" "$target_folder_attachments/$new_bn"
done
......@@ -53,9 +58,9 @@ parse_arguments () {
while getopts 'f:i:mv:' param; do
case "$param" in
f) readonly vault_subfolder="$OPTARG";;
i) readonly input_file=$(realpath "$OPTARG");;
i) readonly input_file=$(/usr/local/bin/realpath "$OPTARG");;
m) readonly move_flag=true;;
v) readonly vault_path=$(realpath "$OPTARG");;
v) readonly vault_path=$(/usr/local/bin/realpath "$OPTARG");;
*) print_usage_and_exit;;
esac
done
......@@ -160,7 +165,7 @@ set_attachments_folder() {
| cut -d '"' -f 4
)
readonly target_folder_attachments=$(
realpath "${vault_path}/${vault_attachments_folder}"
/usr/local/bin/realpath "${target_folder_note}/${vault_attachments_folder}"
)
echo "Attachments folder lives @ '$target_folder_attachments'"
......@@ -209,7 +214,7 @@ validate_input() {
exit 1
fi
readonly target_folder_note=$(realpath "$vault_path/$vault_subfolder")
readonly target_folder_note=$(/usr/local/bin/realpath "$vault_path/$vault_subfolder")
if [ ! -d "$target_folder_note" ]; then
echo "Note folder $target_folder_note doesn't exist in vault, exiting"
exit 1
......