From 4d3fcf3d37dd743deda73b9dbcf360108639b6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Grondek?= Date: Wed, 4 Mar 2020 14:47:54 +0100 Subject: [PATCH] Update sanitaze-folder --- sanitaze-folders.sh | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/sanitaze-folders.sh b/sanitaze-folders.sh index af6d4c8..5b72f35 100755 --- a/sanitaze-folders.sh +++ b/sanitaze-folders.sh @@ -1,6 +1,11 @@ #!/bin/bash -if [ -d "${HOME}/Pobrane" ] +#set -x +set -e + +shopt -s dotglob nullglob + +if [[ -d "${HOME}/Pobrane" && ! -L "${HOME}/Pobrane" ]] then mkdir -p "${HOME}/Downloads" mv ${HOME}/Pobrane/* "${HOME}/Downloads" @@ -9,7 +14,7 @@ then ln -s "${HOME}/Downloads" "${HOME}/Pobrane" echo "Symlinked ${HOME}/Pobrane to ${HOME}/Downloads" else - if [ -L "${HOME}/Pobrane" ] + if [[ -L "${HOME}/Pobrane" ]] then echo "Nothing to do ${HOME}/Pobrane is already symlink" else @@ -17,3 +22,21 @@ else echo "Symlinked ${HOME}/Pobrane to ${HOME}/Downloads" fi fi + +if [[ -d "${HOME}/Dokumenty" && ! -L "${HOME}/Dokumenty" ]] +then + mkdir -p "${HOME}/Documents" + mv ${HOME}/Dokumenty/* "${HOME}/Documents" || true + echo "Moved all download srom ${HOME}/Dokumenty to ${HOME}/Documents" + rmdir "${HOME}/Dokumenty" + ln -s "${HOME}/Documents" "${HOME}/Dokumenty" + echo "Symlinked ${HOME}/Dokumenty to ${HOME}/Documents" +else + if [[ -L "${HOME}/Dokumenty" ]] + then + echo "Nothing to do ${HOME}/Dokumenty is already symlink" + else + ln -s "${HOME}/Documents" "${HOME}/Dokumenty" + echo "Symlinked ${HOME}/Dokumenty to ${HOME}/Documents" + fi +fi