简体   繁体   English

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

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

I have a program that extracted files to a series of sub-folders each with a "header" sub-folder. 我有一个程序将文件解压缩到一系列子文件夹,每个子文件夹都有一个“标题”子文件夹。 For example: 例如:

/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

I'd like to take the files in the specified folder <packagename> and move them up one directory so that the file structure looks like this: 我想获取指定文件夹<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

How can I accomplish this task in bash command line? 如何在bash命令行中完成此任务? Mind you this is an example using 2 folders, I have 100's like this. 请注意,这是一个使用2个文件夹的示例,我有100个像这样。

Share and enjoy. 分享和享受。

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

暂无
暂无

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

相关问题 消除子文件夹,将所有文件移动到一个文件夹中 - Eliminating subfolders to move all files into one folder 如何将所有文件按扩展名移动到指定DIR目录中的子目录? - How to move all files to subdirectories by extension name in the specified DIR directory? 无论文件夹深度或数量如何,复制或移动目录中的所有文件 - Copy or move all files in a directory regardles of folder depth or number 将所有文件夹和文件移动到 Linux 目录中具有相同主题名称的文件夹中 - move all the folders and files to the folder with the same subject name in the directory Linux 如何删除目录中除一个文件夹和一个文件以外的所有文件? - how to delete all files in directory except one folder and one file? 如何将所有文件从一个目录移动(并覆盖)到另一个目录? - How to move (and overwrite) all files from one directory to another? C ++将所有文件从一个目录移动到另一个目录 - C++ move all files from one directory to another 将子文件夹从一个目录移动到另一目录 - move sub folder in one directory to another directory 删除linux目录中的所有文件夹和文件,除了一个文件夹和该文件夹中的所有内容 - delete all folders and files within a linux directory except one folder and all contents inside that folder Shell脚本,它将当前目录中的所有可执行文件移动到单独的文件夹中 - shell script which will move all executable files in the current directory to a seperate folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM