I have a directory with thousands of files. How can I move 100 of the files (any files will do) to another location.
|
|||||||||||||||||||
|
|
If you're not using zsh:
Would move the last (in alphabetical order) 100 ones. |
|||
|
|
|
I know this thread is a pretty old, but I found the answers more complicated than I thought they should be. This worked in CentOS, but it seems simple enough that it should probably work in other distros.
|
|||||||
|
|
Try this:
|
||||
|
mmv is an outstanding utility which will also allow you to do mass renaming of files. (I had to
The backslash is used to show a wildcard is coming up. The */JPG matches anything with a JPG extension. In the "to" portion of the command, the #1 uses the matching text from the first wildcard to rename the file. Of course, you can put a different path before the #1 to also move the file. |
||||
|
The following oneliner in shell would help.
foreach i (`find Source_Directory -type f --max-depth 1|tail -100`); do; {mv $i Target_Directory}; done
|
|||
|
|
|
It's easiest in zsh:
This moves the first 100 files in name lexicographic order. You can select a different sort order with the
With other shells, you can do it in a loop with an early exit.
|
|||||||||
|


about.comand some other website for the list of options available that I can possibly use.. but found nothing liketail– gaijin May 11 '11 at 1:53