Sunday, 8 February 2015

Using "find" to list files with different extentions topic






Hi,

I have films in directory

Code:


~/Films

with different file extentions (.avi, .mp4 and .mkv) and I would like to generate a list of all these movies in a file. Here is the general structure of the "Films" directory:

Code:


/Films
/Films/action/
/Film/action/movie1.avi
/Film/action/movie2.avi
/Film/action/movie3.mkv
/Films/drama/
/Film/drama/movie4.avi
/Film/drama/movie5.mkv
/Film/drama/movie6.mp4
/Films/sci-fi/
...


The different movies are stored in the "action", "drama", "sci-fi" (and so on) sub-directories. I want my list to be:

Code:


movie1.avi
movie2.avi
movie3.mkv
movie4.avi
movie5.mkv
movie6.mp4
...


To acheive this, I tried this command, which is reported to work in some forums:


Code:


cd ~/Films
find . -name "*.mp4" -o -name ".avi" -o -name ".mkv" -fprintf films "%f\n"


which results in the following list in the "films" file:

Code:


movie3.mkv
movie5.mkv


All other titles don't appear.

What is going on?






No comments:

Post a Comment