我在一个文件夹中有大约2000个子文件夹,在每个文件夹中都有.pdf
个文件。我需要一个unix命令,将所有这些文件移到一个文件夹中。
答案 0 :(得分:10)
$ 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
这应该将您的文件复制到/thefolder/
。如果您要移动它们,请将cp
替换为mv
。