开发者

Move all files of same type in multiple directories up one folder

开发者 https://www.devze.com 2023-01-15 10:12 出处:网络
I have about 2000 subfolders in one folder, in each of these folders there are .pdf开发者_如何学C files. I need a unix command that will move all these files up one folder.$ cd thefolder # which conta

I have about 2000 subfolders in one folder, in each of these folders there are .pdf开发者_如何学C files. I need a unix command that will move all these files up one folder.


$ cd thefolder # which contains the subfolders and where the PDFs should land
$ find . -name *.pdf | xargs -I {} cp -iv {} .

# find all files
# which end in .pdf
# recursively from
# the current folder
#                    |
#                      for each emitted line
#                      copy the output (captured by {}) to 
#                      the specified path ('.' is the current directory)
#                      copy should be verbose and should ask,
#                      in case a file would be overwritten

This should copy your files into /thefolder/. If you want to move them replace cp with mv.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号