Skip to content

Instantly share code, notes, and snippets.

@gokhansolak
Created June 4, 2020 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gokhansolak/8059485959b63a348cb2d95b6cdd8f2e to your computer and use it in GitHub Desktop.
Save gokhansolak/8059485959b63a348cb2d95b6cdd8f2e to your computer and use it in GitHub Desktop.
Simple script for compressing all bag files under a folder
#!/bin/bash
# Simple script for compressing all bag files under a folder.
# Optionally, deletes the backup files created by rosbag.
read -p "Compress every bag file under $PWD ? (y/n)" yn
# initial user consent
if [ "$yn" == "n" ]; then
exit 0
fi
# optionally remove backups right away
read -p "Remove original backups? (y/n)" remove_originals
for filename in *.bag; do
[ -f "$filename" ] || break
echo "$filename"
rosbag compress "$filename"
# remove backups if opted
if [ "$remove_originals" == "y" ]; then
extension="${filename##*.}"
basename="${filename%.*}"
rm "${basename}.orig.${extension}"
fi
done
echo done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment