我在一个文件夹中有大约 2000 个子文件夹,每个文件夹中都有 .pdf
文件。我需要一个 unix 命令,它将所有这些文件移到一个文件夹中。
最佳答案
$ 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
。
关于file - 将多个目录中相同类型的所有文件上移一个文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3686860/