Skip to content

Instantly share code, notes, and snippets.

@munzz11
Last active May 30, 2023 20:22
Show Gist options
  • Select an option

  • Save munzz11/2b581f6964ad090d40d876017f9c2c75 to your computer and use it in GitHub Desktop.

Select an option

Save munzz11/2b581f6964ad090d40d876017f9c2c75 to your computer and use it in GitHub Desktop.
Reindex all .active bag files in a dir and delete the .orig.
#!/bin/bash
DIRECTORY="$1"
# Iterate over files in the directory and avoid ._ files. This is an edgecase from having ext4 files on an HFS system
find "$DIRECTORY" -type f -name "*.bag.active" \! -name "._*" | while IFS= read -r file; do
# Index the file
rosbag reindex "$file"
# Get the basename of the original .active.bag file
orig_file="${file%%.*}"
# Delete the file with the ".orig" extension
rm "$orig_file.bag.orig.active"
# Rename the output file without .active
mv "$orig_file.bag.active" "$orig_file.bag"
echo "Processed file: $file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment