Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Revision 0x1
- shopt -s extglob
- confirm() {
- read -p "$1 [Y/n] "
- [[ -z $REPLY || $REPLY = [Yy]?([Ee][Ss]) ]]
- }
- while IFS= read -rd '' f <&3; do
- new=./${f##*/} n=$new i=0
- while [[ -e $n ]]; do
- n=$new.$((++i))
- done
- if ((!i)) || confirm "file '$new' exists, mv to '$n'?"; then
- mv "$f" "$n"
- fi
- done 3< <(find . -mindepth 2 -type f -print0)
- if confirm 'delete dir structure?'; then
- find . -depth -type d -empty -delete
- fi
Advertisement
Add Comment
Please, Sign In to add comment