rename dupes

This commit is contained in:
q
2019-04-11 21:29:27 +03:00
parent 8bbe668c46
commit de67182cc8
3 changed files with 26 additions and 5 deletions

View File

@@ -13,11 +13,12 @@ function clearsafe() {
}
SAFELOC=~/.cache/rm-safe
FOLDERS=()
QUIET="-q"
[[ -z "$1" ]] && helpexit
for ((i=1; i<=${#@}; i++)) {
[[ "${!i}" = "-h" ]] && helpexit
[[ "${!i}" = "--help" ]] && helpexit
[[ "${!i}" = "-v" ]] && { VERBOSE=1; continue; }
[[ "${!i}" = "-v" ]] && { VERBOSE=1; QUIET=""; continue; }
[[ "${!i}" = "--clear" ]] && { clearsafe; continue; }
[[ "${!i}" = "-"* ]] && helpexit
FOLDERS+=( "${!i}" )
@@ -28,8 +29,8 @@ for d in "${FOLDERS[@]}"; do
if [[ ! -e "$d" ]]; then continue; fi
path=$( readlink -f "$d" )
dir=$( dirname "$path" )
if [[ "$VERBOSE" -eq 1 ]]; then echo "$path"; fi
if [[ -e "$SAFELOC/$now/$path" ]]; then file-version -q "$SAFELOC/$now/$path"; fi
if [[ "$VERBOSE" -eq 1 ]]; then echo "$SAFELOC/$now/$path"; fi
if [[ -e "$SAFELOC/$now/$path" ]]; then file-version $QUIET "$SAFELOC/$now/$path"; fi
mkdir -p "$SAFELOC/$now/$dir"
mv "$d" "$SAFELOC/$now/$dir"
done