1

I need to pull all mp4 files from a set of directories with the following type of structure.

Jan
    -Folders
      - -888
      - -777
Feb
   -Folders
     - -888
     - -777

Basically what I need to do is put all the mp4's from the -888 folders in one new directory, all the mp4's from the -777 folders in another new directory and so on.

I tried pulling all the mp4's for all the directories (thinking then I could split them out from there) into a single folder with the following command:

find /myfiles/folders/ iname "*.mp4" -type f -exec /bin/mv {} /videos \; 

This did pull all the mp4 out of my stacks of folders but instead of putting them in the videos directory that I had created, it instead merged them all in a single file called videos. Would love to know what I missed in the script to not make that happen again!

Would appreciate any help!

  • For one thing, you are missing a hyphen at the start of iname. Is that how you actually ran the command? – Wildcard Sep 29 '16 at 20:00
  • And did you really create /videos? Or did you accidentally typo? – Zeta Sep 29 '16 at 20:02
  • How did you get two subdirectories with the same name? You could always temporarily rename(mv) and then switch it back after. – CJ Dana Sep 29 '16 at 20:06
  • If /videos doesn't exist, that would move all files to that name one-by-one, destroying all but the last. I wouldn't call it merging, though. – ilkkachu Sep 29 '16 at 22:50
  • Thanks for all the comments. Answers:I did have the hypen - that was just a typo. I did have a folder called videos to move them into. – user1399145 Oct 1 '16 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.