Copy/Move top 100 files to a directory

I have a large number of files that I need to separate in parts and put in a different directory. I used to copy the files individually and paste them over in a directory. Then I found this cool trick to get the top 100 files from the current directory and copy/move them over to a different one. You can substitute mv/cp based on what you need.

find . -name "*.jpg" -maxdepth 1 -type f | head -100 |  xargs -I{} mv {} Color-Part1/

Keep repeating this command by replacing the name of the directory at the end. Trust me, saves a lot of time.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s