Created
April 16, 2024 17:17
-
-
Save ErykDarnowski/3cb5db1eb465ef1fd05fb4d165d454dc to your computer and use it in GitHub Desktop.
Copy missing files from source to destination dir on Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# THIS ONLY CHECK THE DIFF IN AMOUNT OF FILES, NOT ACTUAL CONTENT!!! | |
# Make sure the SRC path has more files than the DST. | |
SRC_PATH="/d/Games/SteamLibrary/steamapps/common/assettocorsa/content/cars" | |
DST_PATH="//192.168.1.5/home/Backupy/AC Content Manager/content/cars" | |
DIFF_RESULT=$(diff --brief "$DST_PATH" "$SRC_PATH" \ | |
| sed --quiet "s~^Only in \($SRC_PATH\): \(.*\)~'\1\/\2'~p") | |
if [ -n "$DIFF_RESULT" ]; then | |
echo -e "\n" | |
echo "$DIFF_RESULT" \ | |
| xargs cp --recursive --verbose --target-directory="$DST_PATH" | |
echo -e "\n---\n\n@ DONE"; | |
exit 0; | |
else | |
echo -e "\n@ ERR: Nothing to copy!!!"; | |
exit 1; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment