Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to move video files to directory by width of that video file.

For example I have


After running script


If I run script again another width directory is not created.

  • Match common video extensions
  • Do not match if file's parent directory is only digits (because that's the width)

I've come up with this so far but it doesn't work:

find . -type f \( -iname "*.mkv" -o -iname "*.avi" -o -iname "*.mov" -o -iname "*.mpg" -o -iname "*.mpeg" -o -iname "*.wmv" -o -iname "*.mp4" \) -a -regex '.*\/[^0-9]+\/\.*$' -exec bash -c 'echo "Processing {} .."; WIDTH=$(mediainfo "--Inform=Video;%Width%" "{}") && DIR=$(dirname "{}") && mkdir -p "$DIR/$WIDTH" && mv "{}" "$DIR/$WIDTH"' \; 
share|improve this question
Glad were here to help you organize your pr0n 8-). – slm Jan 30 '13 at 22:50

I found your question: use ffmpeg -i YOUR_MOVIE_FILES -sample_fmts You get the long data.

You must use a true grep to retrieve resolution. in this data you can find resolution.

ffmpeg -i YOUR_MOVIE_FILES -sample_fmts |egrep blahblah

or use a awk script.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.