I need to make a script using CMD/Powershell that can find all files in a directory (and subdirectories) that end in extensions associated with media files. I have a Unix script that can do this:
find /directory/ | egrep -e ".*.(jpg|tif|png|gif|wav|mp3|ogg|flac|wma|aac|m4a|flv|webm|ogv|gif|gifv|avi|wmv|mp4|mpg|3gp)"
(I'm sure there's a better way to do this, but it works, and has no problems for me.)
However, I need to do this for Windows. The file types are as follows:
- jpg
- tif
- png
- gif
- wav
- mp3
- ogg
- flac
- wma
- aac
- m4a
- flv
- webm
- ogv
- gif
- gifv
- avi
- wmv
- mp4
- mpg
- 3gp
Edit: Even though I got the right answer, the possible duplicate is not correct. This is because I needed it to be outputted to a file. My script that I wrote using bgalea's answer is as follows:
@ECHO OFF
set $ext=*.jpg *.tif *.png *.gif *.wav *.mp3 *.ogg *.flac *.wma *.aac *.m4a *.flv *.webm *.ogv *.gif *.gifv *.avi *.wmv *.mp4 *.mpg *.3gp
dir /s/b c:\Users%$ext% > mediafiles.txt
echo The locations of the media files were copied to mediafiles.txt
pause