Assigning a directory name to a variable

I am trying to assign a directory name to a variable in the Command Editor. Although Opus will allow me to assign the full path name, I am looking to assign only the lowest level directory name. For example if my path is:
c:\Level1\Level2\Images

While I am in the directory images, I want to be able to write a command that sets a variable with the value "Images"

@set var1 = ?

Thank you in advance.

If you mean the name of the selected item then use {file$|noterm} (works on files and folders).

If you want the name of the current directory then use {sourcepath$|nopath|noterm}

Note that you don't usually need to put these things into a variable. Usually it's best to just use them directly in the command. (That way the command will be able to run each line multiple times if multiple items are selected, for example; variables specifically prevent that from happening.)