Passing only folder name in embedded scripts

Hi All,
I seem to have lost all my old rules,
causing me to recreate many of them. I had a rule set up before that would watch a Compress folder for folders. It would then create a DMG archive with the name of the folder and all its contents.
Easy enough, use hdiutil to create it with an embedded script.
The issue I'm running into is when I pass $1 to the volname, it puts the entire path of the folder as the volume name. But when I pass it to the archive name $1.dmg, it works as expected.
Any idea how I can get the volname correct?
It's minor, but it irks me when I mount the DMG, and it's the entire location for the name, not just the name of the folder, which is how I had it before.
I'm open to doing this another way. I can't recall how it was set up before. If I recall correctly, I found someone who made an Automator Script that did this, and I could call that in Hazel.
Any help would be much appreciated.
I seem to have lost all my old rules,

Easy enough, use hdiutil to create it with an embedded script.
The issue I'm running into is when I pass $1 to the volname, it puts the entire path of the folder as the volume name. But when I pass it to the archive name $1.dmg, it works as expected.
Any idea how I can get the volname correct?
It's minor, but it irks me when I mount the DMG, and it's the entire location for the name, not just the name of the folder, which is how I had it before.
I'm open to doing this another way. I can't recall how it was set up before. If I recall correctly, I found someone who made an Automator Script that did this, and I could call that in Hazel.
Any help would be much appreciated.