unfortunately I have not found a solution for this yet. I would like to run through a folder (incl. subfolders) to find all files with "cover" or "Cover" in the name and then move those into a folder with the same name as its current parent folder, but that new folder is in a different location. So
1st location:
/mnt/folder1/
-- subfolder 1
---- file.mp3
---- cover.jpg
-- subfolder 2
---- file2.mp3
---- cover1.jpg
2nd location:
/mnt/test/folder2
-- subfolder 1
---- otherfile.mp3
---- **cover from subfolder 1 goes here**
-- subfolder 2
---- otherfile2.mp3
---- **cover from subfolder 1 goes here**
The cover files should go from the first location to the second location. I have found out how I can find all the files (find . -type f -name "*Cover*.*"
) but no idea how to move them, as I cannot understand, how I bring this command into the "for f in *cover*.*; do"
format.
Thanks for some guidance!
>Solution :
With absolute paths:
src='/mnt/folder1/'
dst='/mnt/test/folder2'
(
cd "$src" &&
find -type f -name '*[Cc]over*' \
-exec echo mv -iv -- {} "$dst"/{} \;
)
This will display the mv
commands that would be run.
To actually move the files, remove echo
.