如何从多个文件夹中同步特定文件

时间:2019-01-24 21:45:27

标签: rsync

我有两个文件夹

/home/epi/folder1/
home/epi/folder2/

home/epi/destination/

我想将* .txt文件从前两个文件夹移到目标位置,但是有时有5个文件,有时是100k。

我想最多移动40k个文件(合并)(无论其中有多少个文件)。它们可能位于folder1或folder2中,因此在第一步中,我使用find和head生成了一个list.txt,其中包含40k个文件名。

我已经尝试了一些方法,但是由于它们可能位于两个文件夹中,因此很难同时移动这两个特定文件(在列表中)。如果我使用--files-from,它似乎不允许我使用多个源目录。它需要一个,然后期望目标位置。如果不进行说明,则可以指定两个源文件夹并移动所有文件,但是随后,我将移动所有内容。

我尝试使用`cat list.txt`,但是40k的参数列表太大,无法传递到rsync。它适用于较小的数字,但我不希望将同一列表分成多个块多次调用的开销。

a)     rsync -O -av --stats --files-from=list.txt --remove-source-files --log-file=test.log /home/epi/destination

b)     rsync -O -av `cat list.txt` --stats --remove-source-files --log-file=log.txt --progress --temp-dir=/temp /home/epi/destination

有了a)我得到

`rsync error: syntax or usage error (code 1) at options.c(1652) [client=3.0.6]`

使用b)时,由于我得到的参数的大小

`rsync: /usr/bin/rsync: cannot execute [Argument list too long]`

0 个答案:

没有答案