Friday, April 19, 2024
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 19826  / 3 Years ago, tue, may 25, 2021, 9:45:58

I want a command that allows to select specific files based on their extensions to move them to another directory.


More From » command-line

 Answers
3

You can do this easily from one directory with:



mv /path/to/original/directory/*.pdf /path/to/new/directory


The command for a recursive move can be a little more complex. This should do the trick though:



find /original/directory/ | grep '.pdf' | xargs -I {} mv {} /path/to/new/directory/


With the second command /original/directory will be search recursively for .pdf files.


[#32185] Thursday, May 27, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
inaterested

Total Points: 500
Total Questions: 104
Total Answers: 92

Location: Virgin Islands (U.S.)
Member since Fri, May 7, 2021
3 Years ago
inaterested questions
Fri, Aug 12, 22, 21:24, 2 Years ago
Wed, Apr 27, 22, 17:14, 2 Years ago
Tue, Oct 26, 21, 20:41, 3 Years ago
;