I have a folder parentdir
with many directories like this:
$ tree parentdir/subdir_1
parentdir/subdir_1
├── important.txt
├── important_001.txt
├── important_002.log
├── important_007.bmp
├── something
├── else.mp3
├── nothing.000
└── ignore.me
What I want is to move all files with a name starting with important
to the parent directory parentdir
and renaming them by prefixing each file name with the name of the subdirectory they came from.
For example, parentdir/subdir_1/important_001.txt
should be moved/renamed to parentdir/subdir_1-important_001.txt
.
How can I most easily perform this bulk move/rename operation on a huge directory?