I'm trying to copy all media files (Mac file type of Image or Movie) to the same directory structure, only taking media files.
- Is there a more efficient way than what I've got below?
- Is there a mechanism in Mac OS find to get the type of Image or Movie?
- Can this be done without an intermediate tar file? (assume 100,000 media files)
Idea is to:
- Create temporary file list of media files (tar can't take that many files at command line)
- Create tar file
- Extract tar file
Thanks for any advice.
# $1 is the directory to search for media
# $2 is the output file name
media_list() {
find $1 -type f \( -iname "*.JPG" -o -iname "*.JPEG" -o -iname "*.NREF" -o -iname "*.TIFF" -o -iname "*.wmv" -o -iname "*.MOV" -o -iname "*.mp4" -o -iname "*.MPG" -o -iname "*.AVI" -o -iname "*.3g2" -o -iname "*.3gp" -o -iname "*.m4v" \) > $2
}
# $1 is the directory to get media
# $2 is the output tar file name
tar_media() {
rm file-list.txt
media_list $1 file-list.txt
tar -cv -f $2 -I file-list.txt
}