Skip to content

Instantly share code, notes, and snippets.

@hmparanjape
Last active August 29, 2015 14:25
Show Gist options
  • Save hmparanjape/0dd0a927b811262b957e to your computer and use it in GitHub Desktop.
Save hmparanjape/0dd0a927b811262b957e to your computer and use it in GitHub Desktop.
# Display files numbers from an ff directory
# Add this function to ~/.bashrc
function show_ff_data() {
# Find all directories with name ff and loop over them
find "$@" -not -empty -name "ff" -print | while read f; do
# Show directory name
echo "$f"
# Get size of all contents in the directory (in bytes)
tot_byte_size=$(du -b "$f")
# By default du prints the folder name too. Strip that.
tot_byte_size=($tot_byte_size)
tot_byte_size=${tot_byte_size[0]}
# Estimate number of FF frames assuming one frame = 2048*2048*2 bytes
num_frames_estimate=$( echo $tot_byte_size / 8388608 | bc )
# Get size of all contents in a human readable unit (M, G, T)
tot_file_size=$(du -h "$f")
tot_file_size=($tot_file_size)
# Print total size and frame number estimate
echo Total size = ${tot_file_size[0]}, Estimated frames = $num_frames_estimate
# List the contents of the folders
filenames1=$(eval ls \'"$f"\' | tr '\n' ' ')
filelist=''
# Clean up the filenames assuming ff_%5d.ge2 format
for filename in $filenames1
do
filenum1=${filename:3:5}
filenum=$(echo $filenum1 | sed 's/^0*//')
filelist+=", $filenum"
done
filelist1=${filelist:2}
# Print comma separated list of file numbers
echo $filelist1
done
}
@hmparanjape
Copy link
Author

The output of this command can be used in the heXRD config files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment