Can't make "something" into type folder error

Hi,

I have a simple script I am practicing that moves files with a certain name into an existing folder on the desktop, or makes one on the fly. Here is the script:

property babsFolder : "babbles folder"
tell application "Finder"
	if not (exists folder babsFolder) then make new folder with properties {name:babsFolder}
	
	duplicate (every document file of the front Finder window whose name contains "Babbles") to babsFolder
	open this_folder
	
end tell

Here is the error I get:
Finder got an error: Can’t make “babbles folder” into type folder

Can someone tell me what is wrong with this script?
thanks!
babs

Hi,

you should add the keyword folder


 duplicate (every document file of the front Finder window whose name contains "Babbles") to folder babsFolder

Hi Stefen!

OK-that worked as long as the folder didn’t exist…
can you see here, why if the folder exists, the script halts…

property babsFolder : "babbles folder"
tell application "Finder"
	if not (exists folder babsFolder) then make new folder with properties {name:babsFolder}
	
	duplicate (every document file of the front Finder window whose name contains "Babbles") to folder babsFolder
	tell application "Finder"
		open the folder babsFolder of the desktop
	end tell
	
end tell

thanks!
babs

Although desktop is the root folder of the Finder I recommend to add the reference
Try this


property babsFolder : "babbles folder"

tell application "Finder"
	try
		set babsFolder to folder babsFolder of desktop
	on error
		set babsFolder to make new folder at desktop with properties {name:babsFolder}
	end try
	try
		duplicate (every document file of target of front Finder window whose name contains "Babbles") to babsFolder
	end try
	tell application "Finder"
		open babsFolder
	end tell
end tell


A Finder window has no document file element so refer to the target

Hi Stefan
Got it…makes perfect sense :smiley:
thanks!!!
babs