Shell Script for Hazel to change Creation date of a file based on Filename


I had found a script a couple years back that you could paste into Hazel’s Run Script action and it would take the file name of the file (which would be a date) and change the creation date to match it. I can’t seem to find this bash script anymore, does anyone know what I’m talking about of have a different way to go about changing a created date of the file through Hazel? Thanks

Update: I found it hidden deep in my file system (not that deep) in a text file for later use. Thanks past me! Here it is if anyone is interested in using it.

# Take filename, YYYY-MM-DD-New Name.pdf and
# - adjust the creation date using /usr/bin/setfile -d
# - adjust the modification date using /usr/bin/touch
# - rename the file to New Name.pdf using /bin/mv
filename_without_path=$(basename "$1")

YYYY=$(echo "$filename_without_extension_or_path" | awk -F "-" '{print $1}')
MM=$(echo "$filename_without_extension_or_path" | awk -F "-" '{print $2}')
DD=$(echo "$filename_without_extension_or_path" | awk -F "-" '{print $3}')
NNAME=$(echo "$filename_without_extension_or_path" | awk -F "-" '{print $4}')

# Change creation date
/usr/bin/setfile -d "$MM/$DD/$YYYY" "$1"