复制具有无内容的文件名的目录结构

编程入门 行业动态 更新时间:2024-10-21 10:13:41
本文介绍了复制具有无内容的文件名的目录结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

解决方案

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

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

查找目录( -d src / )并在 dest / 或( -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 (*/)

更多推荐

复制具有无内容的文件名的目录结构

本文发布于:2023-10-16 16:34:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498124.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件名   有无   结构   目录   内容

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!