Rsync is a powerful command-line tool for synchronizing files and directories between two locations. However, when syncing macOS files to another location, you may encounter pesky .DS_Store files, which are hidden metadata files created by the Finder. To exclude these files from your rsync operation, you can use the --exclude flag. Below is an example of how to sync files while ignoring .DS_Store files:
### Command Explanation
Let's break down the command step by step:
-`rsync`: This is the command itself.
-`--force`: This option tells rsync to overwrite files without asking for confirmation.
-`-ahviP`: These are a combination of options:
-`-a`: Archive mode, which preserves various attributes of files and directories.
-`-h`: Output numbers in a human-readable format (e.g., 1K, 2M).
-`-v`: Verbose mode, which displays detailed information about the sync process.
-`-i`: Itemize changes, displaying a summary of the changes made.
-`-P`: Equivalent to `--partial --progress`, it keeps partially transferred files and shows progress during transfer.
-`--exclude '.DS_Store'`: This flag tells rsync to exclude any file or directory named `.DS_Store`.
-`--delete`: This option deletes files in the destination that are not present in the source. Be cautious with this option as it can result in data loss if not used carefully.
-`/Users/dimas/Vaults/Photos/`: This is the source directory you want to sync.
-`/Volumes/example/Photos/`: This is the destination directory where you want to sync the files.
### Usage Notes
1.**Source and Destination Paths**: Make sure to replace `/Users/dimas/Vaults/Photos/` and `/Volumes/example/Photos/` with your actual source and destination paths.
2.**Be Careful with --delete**: The `--delete` option can remove files in the destination that are not in the source. Use it with caution to avoid unintentional data loss.
3.**Backup**: Before running any rsync command with the `--delete` option, ensure you have a backup of your data in case something goes wrong.
4.**Hidden Files**: `.DS_Store` files are just one example of hidden files on macOS. You can use the same `--exclude` flag to exclude other hidden files or directories if needed.
With this command, you can effectively synchronize your files and directories while excluding `.DS_Store` files, keeping your destination directory clean and clutter-free.
Feel free to customize the command according to your specific needs, such as excluding other hidden files or directories or adjusting the sync options to suit your preferences.