I have a number of subdirectories and I would like to move any files contained therein to the current directory using a one line Terminal command on the Mac. I know that my file names are not all unique and would like to add a suffix before the file extension.
I found a similar question Q: Move all files in sub-directories to current directory? which suggests using:
find ./*/* -type f -print0 | xargs -0 -J % mv % .
But that's only helpful with unique filenames. For example, given the following tree:
.
├── bar
│ ├── test1.jpg
│ ├── test2.jpg
│ └── test3.jpg
├── foo
│ ├── test1.jpg
│ ├── test2.jpg
│ └── test3.jpg
├── qux
│ └── test3.jpg
└── corge
└── test3.jpg
I would like to see a result similar to:
.
├── bar
├── foo
├── qux
├── corge
├── test1.jpg
├── test1a.jpg
├── test2.jpg
├── test2a.jpg
├── test3.jpg
├── test3a.jpg
├── test3b.jpg
└── test3c.jpg
Can anyone help?