Forum Moderators: bakedjake

Message Too Old, No Replies

find multimedia file names and sizes

how do i do this?

         

bomburmusicmallet

4:50 pm on Jul 25, 2005 (gmt 0)

10+ Year Member



Hi all,

I am monitering a server that many others can upload to. We have "rules" about no multimedia files, but those rules are generally ignored. I ran several find commands to locate multimedia files like this:

find / -name \*.mp3\* -print
find / -name \*.MP3\* -print

What I really want to do is find these files, but not search all directories (for example, I don't want to search our usr/ports directory). I also would like the full path and file name, plus the offending file's size. Is there a way to do this?

Thanks, Jenny

MattyMoose

8:29 pm on Jul 25, 2005 (gmt 0)

10+ Year Member



Hi!

I'm assuming you're using FreeBSD (from the /usr/ports reference), or another *BSD.

The easiest way to do a search like that would be something like:

find /path/to/upload/areas -iname *.mp3

I'm going to assume that your users don't have write access to /usr/ports, so you can probably limit your search to /home, /tmp and /var/tmp (You may need to change /home to /usr/home):

find /home /tmp /var/tmp -iname *.mp3

The -iname tells it to do a case insensitive search (Mp3 is the same as mp3).

To get the additional information you also want, you could do:

find /home /tmp /var/tmp -iname *.mp3 -exec ls -l {} \;

That will give you a long listing of the file. The output would be similar to:

-rw-r--r-- 1 user group 0 Jul 25 13:20 /tmp/test.mp3

I hope that helps!

MM

bomburmusicmallet

1:56 pm on Jul 27, 2005 (gmt 0)

10+ Year Member



Hey MM,

Thanks so much! This is exactly what I need, and I was able to use your code to make a cron job out of it.

Jenny