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