7

I want to select the first 3,000 files in a folder which contains 10,000 files. How do I select only the first 3,000? And if possible, how can I subsequently select the next 3,000 and then 3,000 after that?

I need to copy them into separate folders, each with 3,000 files.

1 Answers1

11

There is no easy method to do that from a stock file manager. You can do it with Shift + Arrow Up (or Arrow Down) but you will need to select the amount of files yourself.

Command line:

This will copy (cp) 3000 files (-n 3000) to /opt/ (-t "$directory"):

cd /dir/with/files/
find . -maxdepth 1 -type f -print0 | head -z -n 3000 | xargs -0 -r -- cp -t "/opt/" --
  • Change 3000 to another number if needed
  • Change /opt/ to your desctination.
  • Use mv -tf to move instead of cp -t when you know cp does what you want (the mv is needed to clear the 3000 files)
Rinzwind
  • 309,379