Created
June 25, 2019 14:04
-
-
Save gm10/bc958a381b83d9c62baf58238c683058 to your computer and use it in GitHub Desktop.
Copy directories while preserving metadata::annotation (Caja Notes)
This file contains 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 | |
# | |
# Copy directories while preserving metadata::annotation | |
# (C) 2019 gm10 | |
# | |
if [[ -z $1 || -z $2 ]]; then | |
echo "Usage: $(basename $0) <source-directory> <target-directory>" | |
exit | |
fi | |
if [[ ! -d $1 ]]; then | |
echo "Source must be a directory" | |
exit | |
fi | |
if [[ -e $2 ]]; then | |
if [[ ! -d $2 ]]; then | |
echo "Destination must be a directory" | |
exit | |
fi | |
else | |
mkdir -p "$2" | |
fi | |
_SOURCE=$1 | |
_DEST=$2 | |
export _SOURCE | |
export _DEST | |
cp -a "$1"/* "$2" | |
find "$1" -exec bash -c ' | |
for f do | |
annotation=$(gio info -a metadata::annotation "$f"|grep metadata::annotation|awk -F '\''metadata::annotation: '\'' '\''{print $2;}'\'') | |
[[ ! -z $annotation ]] && gio set "${_DEST}/${f#"$_SOURCE"}" metadata::annotation "$annotation" | |
done | |
' {} + |
Correction: the original version of 19.3, gio 2.56.4, works.
copy-dir-with-annotation.sh truncates multi line notes to one-liners.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script doesn't find any metadata::annotation on Linux Mint 19.3
The reason seems to be a problem with gio 2.69.1 on Mint 19.3.
gio 2.56.4 on Mint 19.2 works.