复制具有无内容的文件名的目录结构 [英] copy a directory structure with file names without content

查看:104
本文介绍了复制具有无内容的文件名的目录结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个巨大的目录结构的电影文件。为了分析该结构,我想复制整个目录结构,即文件夹和文件,但是我不想复制所有的电影文件,而我想保留文件名。理想情况下,我得到原始电影文件名的零字节文件。



我试过,然后rsync远程机器没有获取链接文件。

解决方案

任何想法如何做到这一点,您可以使用find:

 找到src / -type d -exec mkdir -p dest / {} \; \ 
-o -type f -exec touch dest / {} \;

查找目录( -d src / )并在 dest / mkdir -p $ c>或( -o )查找文件( -f )和 code> dest /



这将导致:

  dest / src /< file-structre> 

您可以使用 mv




$ b


其他(部分)解决方案可以使用rsync实现:

  rsync -a --filter = - !* /sorce_dir / target_dir / 

这里的窍门是 - filter = RULE 选项,排除( - )所有不是的目录( * /


I have a huge directory structure of movie files. For analysis of that structure I want to copy the entire directory structure, i.e. folders and files however I don't want to copy all the movie files while I want to keep there file names. Ideally I get zero-byte files with the original movie file name.

I tried to and then rsync to my remote machine which didn't fetch the link files.

Any ideas how to do that w/o writing scripts?

解决方案

You can use find:

find src/ -type d -exec mkdir -p dest/{} \; \
       -o -type f -exec touch dest/{} \;

Find directory (-d) under (src/) and create (mkdir -p) them under dest/ or (-o) find files (-f) and touch them under dest/.

This will result in:

dest/src/<file-structre>

You can user mv creativly to resolve this issue.


Other (partial) solution can be achieved with rsync:

rsync -a --filter="-! */" sorce_dir/ target_dir/

The trick here is the --filter=RULE option that excludes (-) everything that is not (!) a directory (*/)

这篇关于复制具有无内容的文件名的目录结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆