Created
June 4, 2020 11:14
-
-
Save gokhansolak/8059485959b63a348cb2d95b6cdd8f2e to your computer and use it in GitHub Desktop.
Simple script for compressing all bag files under a folder
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 | |
# 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