SetFile using Developer Tools and Applescript

Hello -

I’m working on changing the file type and creator types of my files. Whenever I download image files from a remote server, OS X always seems to default to Preview. This is all well and good except when I’m writing scripts to make changes to images in Photoshop. The Preview images do not open as expected in Photoshop which creates any number of errors in my script.

Based on an earlier post by Greg Spence, site admin, I wanted to try SetInfo from the Developer Tools. So, here’s my script so far:

repeat with fcFile in fcfileList
set fcfilePath to fcfolder & fcFile as string
try
do shell script "/Developer/Tools/SetInfo -c 8BIM" & fcfilePath
end try
end repeat 

Now, this is just opening a folder with any amount of images in it, and hopefully cycling through them, changing the creator type to open with Photoshop as the default. I think this is getting really close to what I want, except I still have an error.

In my event log, I see this:

tell current application
do shell script "/Developer/Tools/SetInfo -c 8BIM"disk1:Users:pepin:batch:source:disk1:Users:pepin:batch:source:3333.tif
end tell

So there are two issues I can see. One is that my path seems to be wacked out - any suggestions? And that the space between 8BIM and disk1 isn’t resolving correctly. Any help would be greatly appreciated!

-Derek

Does this work?

repeat with fcFile in fcfileList
	set fcfilePath to fcfolder & fcFile as string
	set shellPath to quoted form of POSIX path of fcfilePath
	try
		do shell script "/Developer/Tools/SetInfo -c 8BIM " & shellPath
	end try
end repeat

Sorry, got an error : “Could not get quoted form of POSIX path”. What does that do, anyway?

If you’ve got other suggestions, I’d love to hear them. Thanks!

-Derek

set regularMacPath to "path:to:some:item"
-- > "path:to:some:item"

set posixPath to POSIX path of regularMacPath
-- > "/path/to/some/item"

set quotedForm to quoted form of posixPath
-- > "'/path/to/some/item'" -- note the single quotes

set quotedPosix to quoted form of POSIX path of regularMacPath
-- > "'/path/to/some/item'" -- combines the two commands

These provide a way to prepare a path for the shell. I use the last one in the list most of the time because it does it all in one command.

– Rob

Does the POSIX path work with a list of files that’s being repeated through? Sorry - just trying to figure out how to incorporate that here.

-Derek

Yes, it will work in repeat loops. If you’ll give me an example of a script that works on a single file, I’ll help put it into a repeat loop. If the script uses variables, give me an idea of what the variables hold (path, alias, etc). :slight_smile:

– Rob

Hi -

Actually, I think I stumbled onto an answer just a little bit ago. I was looking at your explanations for regularMacPath and posixPath, and it occurred to me that I could just spell out the path I needed.

for example:

do shell script "/Developer/Tools/SetInfo -c 8BIM /Users/downsizing/Desktop/source/*.tif" 

This way, when I download the files into the same folder, I don’t have to cycle through them with the Finder, I just let Unix do its thang and change every TIFF into a tiff that opens in Photoshop as default. I tried this out and it worked great!

Thanks again for all the help!

-Derek