Testing Embedded Shell Scripts on Catalina - Hazel 4.4

I downgraded my new iMac from Catalina back to Mojave after a week of testing Hazel betas. Now that 4.4 is released I'd like to avoid the time consuming process of updating to Catalina and then needing to downgrade if shell scripts are still a problem for me under 4.4.
Can anyone running 4.4 on Catalina please help me confirm the following embedded script will run? When I tested a few weeks ago, my rules all failed when they got to the shell script. I worked with Hazel support and other problems were quickly resolved, except for this one. I have to thank Noodle Support for their amazing and personal support assistance. I'm reluctant to try this all again until I can get some confidence that the shell script - changing file creation date based on date in filename function will work. I don't have an alternate Mac to test with.
Can someone running the new 4.4 on Catalina please add this shell script as an embedded script, to a rule.
The test case can match any file and then change the file creation date.
The test filename to be re-dated must be in this format: "2019-08-08--Filename to be moved.pdf"
The shell script should change the file creation date to the prepended date in the filename. In this example, the file creation date should get changed to 08/08/2019
Here's my shell script:
By the way, for anyone downgrading from Catalina to back to Mojave, be warned that the Catalina MacOS installation creates a new volume on the hard drive and moves data files there. When you restore Mojave from a backup, that Data partition remains (unless you notice it and remove the new Data partition). It caught me off guard.
Can anyone running 4.4 on Catalina please help me confirm the following embedded script will run? When I tested a few weeks ago, my rules all failed when they got to the shell script. I worked with Hazel support and other problems were quickly resolved, except for this one. I have to thank Noodle Support for their amazing and personal support assistance. I'm reluctant to try this all again until I can get some confidence that the shell script - changing file creation date based on date in filename function will work. I don't have an alternate Mac to test with.
Can someone running the new 4.4 on Catalina please add this shell script as an embedded script, to a rule.
The test case can match any file and then change the file creation date.
The test filename to be re-dated must be in this format: "2019-08-08--Filename to be moved.pdf"
The shell script should change the file creation date to the prepended date in the filename. In this example, the file creation date should get changed to 08/08/2019
Here's my shell script:
- Code: Select all
Shell /bin/bash
# Take filename, YYYY-MM-DD--New Name.pdf and
# - adjust the creation date using /usr/bin/setfile -d
# --------------------------------------------------------------------------
# -- Commented Out --
# - adjust the modification date using /usr/bin/touch
# - rename the file to New Name.pdf using /bin/mv
# --------------------------------------------------------------------------
filename_without_path=$(basename "$1")
extension="${filename_without_path##*.}"
filename_without_extension_or_path="${filename_without_path%.*}"
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"
# --------------------------------------------------
# -- Commented Out --
# Change modification date to Today/Now
# /usr/bin/touch "$1"
# Rename file
# /bin/mv "$1" "$NNAME"
# --------------------------------------------------
By the way, for anyone downgrading from Catalina to back to Mojave, be warned that the Catalina MacOS installation creates a new volume on the hard drive and moves data files there. When you restore Mojave from a backup, that Data partition remains (unless you notice it and remove the new Data partition). It caught me off guard.