Banging head against wall on a simple element... Move Folder command!

So, I have a script that is handling files nested within various folders and I after the script shakes its booty, I want to rename the folder the files are contained in, rename it and, move it. It is when the script goes to move the folder that I get the following error:

Snippets of the script are below:

tell application "Finder"
	set targetFolder to (choose folder)
	set folderPath to (targetFolder as string)
	set folderName to name of folder targetFolder
	set folderNames to name of every folder in targetFolder
	set numFolders to count of folderNames
set workingFolder to (folderPath & thisFolder & ":CD01") as alias

-- *******....snip....******

set name of folder workingFolder to (folderName & "_CD")
set renamedFolder to (folderPath & thisFolder & ":" & folderName & "_CD:") as alias
move renamedFolder to "Users:scottc:Desktop:results:"

end tell

Any help will be greatly appreciated.

Edit (Bruce Phillips): Removed image tag, put in error message.

OK! and why didn’t the image post!

The image tag is turned off (look on any Post Reply page).

The move verb requires a reference for both the object being moved and the destination.


set FolderToMove to choose folder with prompt "Select folder to be moved."
set DestinationFolder to choose folder with prompt "Select folder destination."

tell app "Finder"
   move folder FolderToMove to folder DestinationFolder
end tell

HTH
Craig

AppleScript: 1.10.2
Browser: Safari 416.2
Operating System: Mac OS X (10.4)

Thanks, Bruce - that makes it clearer that the problem is not when the script tries to move the folder, but in the preceding line - where it tries to define the path to ‘renamedFolder’.

Trouble is, I’m having some difficulty working out exactly what the aim is here - partly because I can’t see where or how the variable ‘thisFolder’ was first defined… :confused:

I didn’t think anyone would be interested in the entire script… but here it is, anyway…


--on adding folder items to targetFolder after receiving newItems

set my_fields to {{"Whi", string}, {"Front", string}}
set my_db to DB create with properties {DBName:"FrontlineCodes", DBFields:my_fields}
set my_records to {{"3.5x5 Print", "A"}, {"4x6 Print", "C"}, {"5x7 Print", "E"}, {"6.5x10 Print", "F"}, {"6x8 Print", "S"}, {"8 Wallet Prints", "W"}, {"8x10 Print", "H"}, {"8x12 Print", "I"}, {"10x15 Print", "L"}, {"Burn to CD", "X"}}
set my_db to DB add records my_records to db my_db

set x to 1
set y to 1

tell application "Finder"
	set targetFolder to (choose folder)
	set folderPath to (targetFolder as string)
	set folderName to name of folder targetFolder
	set folderNames to name of every folder in targetFolder
	set numFolders to count of folderNames
end tell

tell application "Finder" to set itExists to (exists the file (folderPath & "info.txt"))
if itExists is true then
	tell application "TextEdit"
		activate
		open file (folderPath & "info.txt")
		tell front document
			copy (the first word of paragraph 11) to custID
		end tell
		close front document
	end tell
else
	set custID to (text items -6 through -2 of folderPath) as text
end if

--	count the items in the first folder, set the text file, go to the next folder
repeat with m from y to numFolders
	set thisFolder to (item y of folderNames)
	if thisFolder is "Index Print" then
		tell application "Finder"
			delete (folderPath & thisFolder)
		end tell
	else
		if thisFolder is "Burn to CD" then
			set workingFolder to (folderPath & thisFolder & ":CD01") as alias
		else
			set workingFolder to (folderPath & thisFolder) as alias
		end if
		tell application "Finder" to set filenames to name of every item of workingFolder
		try
			set flCode to DB get data from db my_db fields "Frontline" where {"Field(Whitech)", "=", thisFolder}
		on error
			display dialog "You haven't setup that Frontline Code yet."
		end try
		set numFiles to count of every item of filenames
		
		tell application "BBEdit"
			activate
			set docRef to make new text document
			tell docRef
				set text of it to "Customer: " & custID & return & ¬
					"Sort: " & targetFolder & return & ¬
					"Code: " & flCode
				repeat with n from x to numFiles
					set fileNamesX to (item x of filenames)
					set line (x + 3) to (return & "Add: " & (ASCII character 34) & fileNamesX & (ASCII character 34) & " " & 1)
					set x to (x + 1)
				end repeat
				set x to 1
			end tell
			save docRef to ((workingFolder as string) & "order.inf")
			close docRef
		end tell
	end if
	set y to (y + 1)

	tell application "Finder"
		if itExists = true then
			set name of folder (folderPath & thisFolder) to (folderName & "_" & thisFolder)
--need to fix the above command...
		else
			
			set name of folder workingFolder to (folderName & "_CD")
			set renamedFolder to (folderPath & thisFolder & ":" & folderName & "_CD:") as alias
			move folder renamedFolder to folder "Users:scottc:Desktop:results:"
		end if
		--move folder thisFolder to "Users:scottc:Desktop:results:"
	end tell
end repeat

beep 3
--end adding folder items to


Awesome!! Thanks!

Altered the code in question to be -


			set name of folder workingFolder to (folderName & "_CD")
			set renamedFolder to (folderPath & thisFolder & ":" & folderName & "_CD:") as alias
			set destinationFolder to "Macintosh HD:Users:scottc:Desktop:results:" as alias
			move folder renamedFolder to folder destinationFolder

Yes, I see that… but how can we turn it on?

You can’t. However, you can link to an image.