Created
January 11, 2020 07:27
-
-
Save entendu/275bbeb159d42f8c62601772c77c7cfd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dest="../dst-test"; find . -type d -mindepth 1 -exec mkdir -p "$dest/"{} \; find . -type f -print0 | while IFS= read -r -d '' file; do if [[ "$(basename "$(dirname "$file")")" =~ ^[0-9]{4} ]]; then newfile=$(basename "$file"); else newfile=$file; fi; if [[ -f "$dest/$newfile" ]]; then i=1; until [[ ! -f "$dest/$newfile-$i" ]]; do ((i++)); done; newfile="$file-$i"; fi; echo "mv $file $dest/$newfile"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment