0

I'm working with some PhotoRec output files, and I'm only interested in files that are larger than a certain size threshold let's say 10M. I've found ways to sort recursively in other posts (Sorting files according to size recursively) but I couldn't quite figure out let's say move all of these files to a different location.

Right now the structure of the folders looks something like this:


parent folder

  • re1
  • re2
  • re...
  • See also related posts: https://unix.stackexchange.com/questions/484791/bash-find-move-files-bigger-than-certain-size and https://unix.stackexchange.com/questions/310085/how-do-i-move-files-based-on-size I will mark it as a duplicate but I have also added an answer to do this with one mv process. – thanasisp Oct 28 '20 at 05:21

1 Answers1

1

You can use this find command, to find and move all files with size more than 10M.

find . -type f -size +10M -exec mv -t path/to/target/dir {} +

Using this syntax, we use ony one mv process for all the files, or better to say, only as many processes as necessary, as in case of too many arguments, this is handled internally and a second, third etc process could be raised, if needed.

When it can be used, that means where we can execute the command with multiple arguments, it is better from the syntax -exec <command> {} \; where one process per argument is raised. The important thing to use {} + is that nothing can exist between the curly braces and the +, so for the mv command we have to use the -t parameter to define the target directory.

thanasisp
  • 8,122