How to move some files to their parent directory?
Solution 1:
Try:
find . -path "*/flac/*" -name '*.mp3' -execdir mv -t ../ {} +
How it works
-
find .
Start a find command working on the current directory.
-
-path "*/flac/*"
Select only files with
flac
in their path -
-name '*.mp3'
Select only files with extension
.mp3
. -
-execdir mv -t ../ {} +
For any files found run the
mv
command from the directory that the file is in and move the file to the parent directory.In addition to making this particular task easy, the option
-execdir
is also more secure than than the traditional-exec
option.
Simplification
find . -path "*/flac/*.mp3" -execdir mv -t ../ {} +