File moving

I’ve had a quick search but couldnt find this question being raised before, but I apologise if it has and I’ve missed it.

I’m trying to write a droplet type script that allows me to drop in one or more folders containing raw photos from my nikon camera (.NEF), and with each folder, create a subfolder called “Raw” and move all the .NEF files into that. I’m having difficulty getting the move to work though, and this is my first apple script so I’m getting a bit stumped.

Here’s what I’ve got so far:

on open these_items
	repeat with i from 1 to the count of these_items
		set this_item to (item i of these_items)
		set the item_info to info for this_item
		if folder of the item_info is true then
			tell application "Finder"
				-- The name of the folder to put NEF files into
				set rawFolderName to "Raw"
				make new folder at this_item with properties {name:rawFolderName}
				move every item of folder this_item to rawFolderName
			end tell
		end if
	end repeat
end open

When I run this, I get an error saying can’t get every item of <> … Presumably this is because the move x to y needs y to be an absolute path of drive:folder:folder:folder style, and I’m not giving it one. If that’s the case, how do I concatenate my rawFolderName variable onto the location of this_item? I would also like to only move files ending in .NEF, but couldn’t figure that out either. Something to do with item_info?

Thanks!

Model: PowerBook (current rev) 1.5GHz/1Gb/80Gb
AppleScript: 1.10
Browser: Firefox 1.0.6
Operating System: Mac OS X (10.4)

You’ve put your finger on the essence of the problem, Jesty. However, there’s no need to worry about concatenation, since Finder will give you a reference when you make the new folder. It should also be able to filter the required files for you - something like this:

on open these_items
	repeat with this_item in these_items
		if folder of (info for this_item) then tell application "Finder" to ¬
			move (files of folder this_item whose name extension is "NEF") to ¬
				(make new folder at this_item with properties {name:"RAW"})
	end repeat
end open

You sir, are a scholar and a gentleman. I’ve been tearing my hair out for hours trying to get this working!

Thanks a bunch :smiley: