0

I would like to move the last few files of the find command's output. The only way I can think of is:

find ~/place -iname '*.mp4' -ok mv{} ~/someplace \;

However, there are so many files that it becomes tedious to keep typing no for the ones i do not want to move. Moreover, the ones I am interested in all have capital letters in them. Is there a better way to do this?

  • There are lots of ways to filter the output, if the files you don't want to move have something in common... – Zanna Oct 10 '16 at 17:08
  • So, what files do you want to move if you don't want to move all of the .mp4 files? – TheOdd Oct 10 '16 at 17:08
  • @OwenHines There are lectures and movie snippets that I took. – Ceelogre Oct 10 '16 at 17:10
  • Is there a specific format/pattern for the files that you want that distinguish them from the others? – TheOdd Oct 10 '16 at 17:11
  • @Zanna yeah the have something in common, they all have capital letters in them. – Ceelogre Oct 10 '16 at 17:11
4

If the filename is entirely capital letters except for the .mp4 part, you can use find's -regex option:

find ~/place -regex '.*/[A-Z]*.mp4' -exec mv -t ~/someplace {} +

If the mp4 is also uppercase, then modify accordingly. Using mv -t ~/someplace lets you use -exec ... {} + form, so that multiple files are moved together. The .*/ matches the path before the filename.

  • Thanks that worked out. So sad I can't upvote your answer :( – Ceelogre Oct 10 '16 at 17:33
  • @samuel that's alright – muru Oct 10 '16 at 17:34

Your Answer

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

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