diff --git a/borgaliasandfunctions.txt b/borgaliasandfunctions.txt index bec2171..e3d483e 100644 --- a/borgaliasandfunctions.txt +++ b/borgaliasandfunctions.txt @@ -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 } \ No newline at end of file