Apple - Prepend folder names to file name and flatten file structure
Tricky one, especially if you want to keep all the spaces etc. Run the following in the top directory (the one which contains 2013-02 Snow and birds
etc):
find . -type f -exec sh -c 'for f do x=${f#./}; echo mv "$x" "${x////_}"; done' {} +
The assignment to x
gets rid of the leading ./
from find
, the ${x////_}
replaces all (remaining) occurrences of /
with _
.
Also, I've protected the actual mv
with an echo
so you can verify first whether the commands look ok. Rerun the command without the echo
to actually rename/move the files.