繁体   English   中英

将指定文件夹中的所有文件移到一个目录中

[英]Move all files in specified folder up one directory

我有一个程序将文件解压缩到一系列子文件夹,每个子文件夹都有一个“标题”子文件夹。 例如:

/share/Videos/Godfather.Part.1
  /share/Videos/Godfather.Part.1/<packagename>
    /share/Videos/Godfather.Part.1/<packagename>/Godfather.avi
/share/Videos/Godfather.Part.2
  /share/Videos/Godfather.Part.2/<packagename>
    /share/Videos/Godfather.Part.2/<packagename>/Godfather2.avi

我想获取指定文件夹<packagename>中的文件并将它们向上移动一个目录,以便文件结构如下所示:

/share/Videos/Godfather.Part.1
  /share/Videos/Godfather.Part.1/Godfather.avi
/share/Videos/Godfather.Part.2
  /share/Videos/Godfather.Part.2/Godfather2.avi

如何在bash命令行中完成此任务? 请注意,这是一个使用2个文件夹的示例,我有100个像这样。

分享和享受。

for i in `find . -name "*avi"`
do
    dest=`dirname $i`
    mv $i $dest/..
done

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM