[英]how to copy files with subfolders
I have folder with subfolders and files inside.我有一个文件夹,里面有子文件夹和文件。 I want to copy all html files from all subfolders in main folder (parent) and have it in new folder (dist) with the same folder structure.
我想从主文件夹(父)中的所有子文件夹中复制所有 html 文件,并将其放在具有相同文件夹结构的新文件夹(dist)中。 (I am using Mac)
(我使用的是 Mac)
parent
subfolder1 - file1.html, file4.html
subfolder2 - file2.html
subfolder3 - file3.html
Expected result is dist folder with structure the same as in parent folder:预期结果是结构与父文件夹相同的 dist 文件夹:
dist
subfolder1 - file1.html, file4.html
subfolder2 - file2.html
subfolder3 - file3.html
I am using this command:我正在使用这个命令:
cp -R ./parent/templates/**/*.html ./dist/templates
But the result is templates folder filled up with.html files but no subfolders copied.但结果是模板文件夹充满了.html 文件,但没有复制子文件夹。
dist
file1.html
file2.html
file3.html
file4.html
So I am not sure how to do it.所以我不知道该怎么做。
how to do it.
怎么做。
With GNU cp
you could try:使用 GNU
cp
你可以尝试:
cd ./parent/templates/ &&
cp -R --parents **/*.html ../../dist/templates
But I would recommend to use rsync
.但我建议使用
rsync
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.