Skip to content

Instantly share code, notes, and snippets.

@Golumpa
Last active February 3, 2022 20:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Golumpa/89e3d3eeb810d7f8f539b61cffe5b29b to your computer and use it in GitHub Desktop.
Save Golumpa/89e3d3eeb810d7f8f539b61cffe5b29b to your computer and use it in GitHub Desktop.
#!/bin/bash
# This simple bash script adds a CRC32 to the end of every file in a chosen folder. It will not add them recursively.
# This script needs libarchive-zip-perl (Debian based), perl-Archive-Zip (Red Hat based) installed to be able to run.
# Change this to the folder that have files you want to add CRC32's to.
home="FolderName"
# This filters out those files you want to add a CRC32 to.
ext="mkv"
while read a; do
i=`basename "${a}"`;
crc=`crc32 "${home}/${i}" | awk '{print toupper($0)}'`;
mv "${home}/${i}" "${home}/${i%%.*} [${crc}].${ext}";
done < <(find "${home}/" -type f -name \*.${ext})
@Fiwi1265
Copy link

Fiwi1265 commented Feb 1, 2022

Thanks, but you should change the extension of the file to sh.

@Golumpa
Copy link
Author

Golumpa commented Feb 3, 2022

@Fiwi1265 Thanks for reminding me, I did it way back as a joke to a friend as he kept naming his bash files as .bat and forgot to change it back.

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