Reputation: 173
I am using Ubuntu
and I am needing to recursively search a directory and subs for any .mp4
, .mkv
, or .wav
files. I saw that mmv
may be my best solution, but I can not get the syntax correct. So how would I convert this to search for an array of file names, or would I just want to run 3 iterations for each file extension I am after?
I was using the tutorial here to write this, so please forgive me if I am way outta line find all m3
# find / -iname "*.mp4" -type f -exec mv {} ./Downloads/Media Files \;
Upvotes: 0
Views: 235
Reputation: 29
Replace -iname with -regex. Regex understands emacs regular expressions by default (but you can change this behaviour using -regextype):
find / -regex ".*\.mp4\|.*\.mkv\|.*\.wav" ...
Learn the power of reguar expressions, it will open a new universe of power!
Upvotes: 0
Reputation: 88644
With GNU bash 4:
shopt -s globstar nullglob
mv -v **/*.{mp4,mkv,wav} ./Downloads/Media Files
globstar
: If set, the pattern ** used in a pathname expansion context will match all files and zero or more directories and subdirectories. If the pattern is followed by a /, only directories and subdirectories match.
nullglob
: If set, bash allows patterns which match no files (see Pathname Expansion) to expand to a null string, rather than themselves.
Upvotes: 2
Reputation: 69218
You can use \(
and -o
(or):
find / -type f \( -iname "*.mp4" -o -iname "*.mkv" -o -iname "*.wav" \) -exec mv {} ./Downloads/Media Files \;
Upvotes: 2