MacOS – AppleScript: alias reference is not changing after renaming a folder

aliasapplescriptmacos

I'm new to AppleScript and after doing:

set folder_name to "New_Folder"
tell application "Finder" to make new folder at desktop
set my_folder to result as alias
tell application "Finder" to set the name of my_folder to folder_name
get my_folder

I get: alias "/Users/frank/Desktop/untitled folder"

I thought alias was dynamic, why my_folder reference is not changing after renaming the folder?
i.e. alias "/Users/frank/Desktop/New_Folder"

How can I accomplish that?

Best Answer

I'm not quite sure why you're not getting the correct information. Running your code on my system (macOS High Sierra) returns the correct alias to the renamed folder.

enter image description here

This code should return the proper value for the alias value you are looking for

set folder_name to "New_Folder"
tell application "Finder" to set my_folder to ¬
    (make new folder at desktop with properties {name:folder_name}) as alias
return my_folder