β Created by ChatGPT π€
It does not move the parent folder by default β this trips a lot of people up.
rsync copies the contents of the source directory, and whether the parent folder itself appears at the destination depends on the trailing slash.
The key rule (trailing slash matters a lot)
1οΈβ£ With a trailing slash β copies contents only
rsync -av source_dir/ dest_dir/
Result:
dest_dir/
βββ file1
βββ file2
βββ subdir/
source_dir itself is not created inside dest_dir.
2οΈβ£ Without a trailing slash β copies the folder itself
rsync -av source_dir dest_dir/
Result:
dest_dir/
βββ source_dir/
βββ file1
βββ file2
βββ subdir/
Here, the parent folder is included.
If you mean βmoveβ instead of copy
rsync is a copy tool. To move, you add:
--remove-source-files
β¦but that only removes files, not directories, so youβd usually follow with:
find source_dir -type d -empty -delete
Or just use:
mv source_dir dest_dir/
if itβs local and simple.
TL;DR
- Trailing slash = no parent folder
- No trailing slash = parent folder included
rsynccopies by default, doesnβt move unless you force it
If you want, tell me what youβre trying to end up with and Iβll give you the exact command π