簡體   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