1

さまざまなサブフォルダーにある一連のflacファイルを宛先のフォルダーのルートに同期したいと思います。

ソースのディレクトリ構造の例は次のとおりです。

source> tree Music/
Music/
├── R
│   ├── Radiohead
│   │   └── OK Computer
│   │       ├── 01 - Radiohead - Airbag.flac
│   │       ├── 02 - Radiohead - Paranoid Android.flac
│   └── Red Hot Chilli Peppers
│       └── Greatest Hits
│           ├── 01 - Red Hot Chili Peppers - Under the Bridge.flac
│           ├── 02 - Red Hot Chili Peppers - Give It Away.flac

私はこのコマンドを使用しています。これは正常に同期しますが、宛先のディレクトリパスが含まれています。

rsync -rltDzvh --delete -e ssh Music/ user@192.168.1.1:/Destination/ --include="*/" --include="*.flac" --exclude="*"

したがって、宛先の構造は次のとおりです。

destination> tree /Destination/
/Destination/
├── R
│   ├── Radiohead
│   │   └── OK Computer
│   │       ├── 01 - Radiohead - Airbag.flac
│   │       ├── 02 - Radiohead - Paranoid Android.flac
│   └── Red Hot Chilli Peppers
│       └── Greatest Hits
│           ├── 01 - Red Hot Chili Peppers - Under the Bridge.flac
│           ├── 02 - Red Hot Chili Peppers - Give It Away.flac

すべてのディレクトリを整理して、ファイルのみが/Destination/のルートに配置されるようにします。

destination> tree /Destination/
/Destination/
├── 01 - Radiohead - Airbag.flac
├── 02 - Radiohead - Paranoid Android.flac
├── 01 - Red Hot Chili Peppers - Under the Bridge.flac
├── 02 - Red Hot Chili Peppers - Give It Away.flac

すべてのファイルの名前が異なるので問題ありません。rsyncの--no-relativeなどのさまざまなオプションを確認しましたが、期待どおりに機能させることができませんでした。

私も思いついた:

find ./Music/ -name "*.flac" -exec rsync -ltDzvh {} -e ssh user@192.168.1.1:/Destination/ \;

しかし、これはsshキーを使用することを意味し、おそらく非効率的であり、-deleteを使用したい場合は、すべてが壊れてしまう可能性があります。

では、ソースのミュージックライブラリのアイテムを追加、削除、または名前変更し、それらの変更を宛先に同期させるときに、-deleteまたは--delete-excludedを使用しながら、これをどのように実現できますか?

4

0 に答える 0