I have the following loop in zsh:
for x in my_folders*;
do
rsync -adrv $x/foo/bar/ /foo2/bar2/new_dir/$x/
done
new_dir does not exist before calling rsync, and I would like rsync to create it, along with everything else needed for the copy operation.
I am passing rsync the flags d and r but it complains with:
rsync: mkdir "/foo2/bar2/new_dir/item1" failed: No such file or directory (2)
It apparently assumes that the folders /foo2/bar2/new_dir/$x/ exist prior to the copying, which don't. With this:
- Is there a way to ask rsync to create any necessary directories needed for the copy operation to work?