33 lines
647 B
Bash
33 lines
647 B
Bash
|
#!/usr/bin/bash
|
||
|
#
|
||
|
# Dolphin keeps old paths after modifications.
|
||
|
# Run with '--do-it' to really make the change.
|
||
|
#
|
||
|
set -eu
|
||
|
|
||
|
do="${1:-}"
|
||
|
|
||
|
bmk=".local/share/user-places.xbel"
|
||
|
rt="/srv/samba/schools/default-school/students"
|
||
|
|
||
|
extract() {
|
||
|
local grp="$1"
|
||
|
grp="${grp##*${rt}/}"
|
||
|
grp="${grp%%/*}"
|
||
|
echo $grp
|
||
|
}
|
||
|
|
||
|
for f in $(find $rt/*/*/$bmk) ; do
|
||
|
cor="$(extract $f)"
|
||
|
for l in "$(grep "$rt" "$f")" ; do
|
||
|
fnd="$(extract "$l")"
|
||
|
if [[ "$cor" != "$fnd" ]] ; then
|
||
|
echo "Check ${f##*${rt}/}: '$cor' != '$fnd'."
|
||
|
if [[ "$do" = "--do-it" ]] ; then
|
||
|
sed -i.lmn-fix-path "s|$rt/$fnd|$rt/$cor|g" "$f"
|
||
|
break
|
||
|
fi
|
||
|
fi
|
||
|
done
|
||
|
done
|