如何从所有目录(即Case-r20-c020-t001-da1
...)复制图像文件夹,Case-r20-c020-t001-dan
在新路径中保留原始目录名称(例如Case-r20-c020-t001-da1
...)Case-r20-c020-t001-dan
。假设我的目录结构如下:
Case-r20-c020-t001-da1/
|____image/ <<<< This is a folder that has some pictures
|______ jpg
|______ png
|____infromation/ <<<< This is a folder.
|_______ text1.txt
|_______ text2.txt
|____ file1.txt
Case-r20-c020-t001-da2/
|____image/
|______ jpg
|______ png
|____infromation/
|_______ text1.txt
|_______ text2.txt
|____ file1.txt
:。
Case-r20-c020-t001-dan/ <<< n goes from 3,...20.
|____image/
|______ jpg
|______ png
|____infromation/
|_______ text1.txt
|_______ text2.txt
|____ file1.txt
我最初的尝试如下。
for f in Case-r20-c020-t001-da*;do (cp -r images /path/folder*);done
因此,我想将以上内容复制到新的目录中,并且输出必须如下所示;
Case-r20-c020-t001-da1_images/
|____image/
|______ jpg
|______ png
Case-r20-c020-t001-da2_images/
|____image/
|______ jpg
|______ png
:。
Case-r20-c020-t001-dan_images/
|____image/
|______ jpg
|______ png
我更喜欢成为一个命令。
任何帮助,将不胜感激。
谢谢,
作为一个小脚本,这会更清楚,但是在这里,它是作为一个命令编写的。为了清楚起见,它分为两行:如果希望将两行连接在一起,请删除反斜杠。
for old in /old/path/Case-r20-c020-t001-da*; \
do new="/new/path/$(basename $old)_images"; mkdir -p "$new" && cp -r "$old/image" "$new/"; done
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句