Skip to content

Instantly share code, notes, and snippets.

@bramtechs
Created July 19, 2023 12:20
Show Gist options
  • Save bramtechs/f2810c8f71bf43b4b21e503d9a4f1ea2 to your computer and use it in GitHub Desktop.
Save bramtechs/f2810c8f71bf43b4b21e503d9a4f1ea2 to your computer and use it in GitHub Desktop.
Bash script that generates csv of file tree (path to file, size and md5 hash)
#!/bin/bash
RUN_DIR=$1
if [ -z "$1" ]; then
echo "Usage: $0 <directory of game distribution>"
exit 1
fi
echo Generating index of $RUN_DIR ...
pushd $RUN_DIR
# write csv headers
echo "file,size,hash" > index.csv
find . -type f -print0 | while read -d $'\0' file; do
echo $file
FILE_SIZE=$(stat -c%s "$file")
FILE_HASH=($(md5sum "$file"))
echo "$file,$FILE_SIZE,$FILE_HASH" >> index.csv
done
cat index.csv
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment