I want to pull all mp3's that accidentially have been put into a flac folder out of it, to their parent folder.
It should not matter how deep the folders are, I just want to move the matching files exactly one directory up.
Here's how I select my files:
find . -path "*/flac/*" -name '*.mp3'
This works from my music folder, but I am stuck here. All solutions I have found, either move the files to the parent of the current folder, or require some fixed structure.
Best Answer
Try:
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