Set folder name to text string variable?

Hi,
Is it possible to set a folder name to a name taken from a text string of a variable?

Here’s part of a script that I’m working on that should set the artist name to a new folder, named “untitled folder”. This would change the folder name from “untitled folder” to " whatever artist name ". If there’s some method for setting the name of the new folder right away I guess that would get the job done too.

This script seems to work if you check the log on the script editor but it does NOT change the actual folder names in Finder.

Script:


property separator : " / "
set AppleScript's text item delimiters to {""}
tell application "iTunes"
	set curSongs to selection
	repeat with thisSong in curSongs
		set fileloc to location of thisSong as alias
		set details to artist of thisSong & " / " & album of thisSong
		set comment of thisSong to details
		set AppleScript's text item delimiters to " / "
		set txt to text items of details
		set artistName to text item 1 of txt
		set albumName to text item 2 of txt
		tell application "Finder"
			set musicFolder to folder of folder of folder of fileloc
			set x to folders in musicFolder --make new folder under this line
			make new folder in musicFolder
			repeat with x in musicFolder
				set newFolderName to artistName as string
				if name of x contains "untitled folder" then
					set name of x to newFolderName
				end if
			end repeat
		end tell
		set AppleScript's text item delimiters to {""}
	end repeat
end tell
beep

If you’re going to test this script out try just selecting one song from your iTunes library (if you don’t select any songs it won’t work).

Sorry I forgot to mention this!

I wasn’t going to test it, but assuming that you can get the text string you want then:


set tName to "greenyouse"
tell application "Finder" to set NF to make new folder at desktop with properties {name:tName}
--> NF is set to: folder "greenyouse" of folder "Desktop" of folder "bell" of folder "Users" of startup disk

Wow, that was really easy. I’ve been trying to get that for about four days straight. Thanks for the tip!