adding bobarenamer

This commit is contained in:
Djan 2021-04-05 11:17:28 +02:00
parent ab2410f7bc
commit 72e9716743
1 changed files with 44 additions and 0 deletions

View File

@ -121,4 +121,48 @@ function bobadeleter {
$editor $file
sh $file
rm $file
}
# mass archive renaming
function bobarenamer {
TestBorgRepo
if [ "$TestBorgErr" = "1" ]; then return;fi
which paste || echo "Paste command not found." exit
borgrepo="${PWD##*/}"
file="file_$borgrepo.txt"
originals="originals_$borgrepo.txt"
script="borgrenamer_$borgrepo.sh"
echo "Generating list of archives..."
borg list --short . >> $originals
if [ "$?" != "0" ]; then echo "Error generating list of archives. Exiting." && return;fi
cp $originals $file
$EDITOR $file
sed -i 's/^/"/' $originals
sed -i 's/$/"/' $originals
sed -i 's/^/borg rename -v .::/' $originals
sed -i 's/^/"/' $file
sed -i 's/$/"/' $file
paste -d" " $originals $file > $script
sed -i '1s/^/\n/' $script
sed -i '1s/^/\n/' $script
sed -i '1s/^/BORG_PASSPHRASE=\"\"\n/' $script
sed -i '1s/^/#Quick and dirty fix for repo with passphrase\n/' $script
sed -i '1s/^/\n/' $script
sed -i '1s/^/#Modifications in this file will be applied\, comment all to cancel\.\n/' $script
sed -i '1s/^/### BORG RENAMER ###\n/' $script
$EDITOR $script
echo "Renaming..."
sh $script
rm $file
rm $originals
rm $script
}