Moving files

Hi!
I’d like to move backup preferences to the original Preferences folder as a script. Seems like an easy chore, right? Then why am I so confused?

It’s basically iSight preferences that might have been changed after a user has been on the machine. So I’d like to make a startup script that replaces the changed prefs with the originals that I have in a backup location (on the same drive).

Thank you so much…

I’m fairly new to this, but this seems to work:


tell application "Finder"
	delete "DriveA:pathA:wrongpreferences"
	duplicate file "DriveA:pathB:correctpreferences" to folder "DriveA:pathA:"
end tell

Cheers


set theFile to resource path of main bundle of me & "/myFile.jpg"
-- theFile is now "/Users/eeliason/myApp/build/myApp.app/Contents/Resources/myFile.jpg"
set myPath to ":Users:eeliason:myApp:build:myApp.app:Contents:Resources:myFile.jpg"

tell application "Finder" to duplicate theFile to desktop as alias without replacing

The above code works as is, given that I’ve hard coded the value for theFile. Note, however, that the path is identical to that returned by the first line of code, which is what I need in order to get an absolute path to the application itself on any system.

Sooo…why doesn’t the path with ‘/’ delimeters work? Is there a simple way around this? Or should I write a little handler to replace all ‘/’ with ‘:’ and be done with it?

THANKS!

To translate a slash-delimited path to a colon-delimited one, use ‘posix file’…

set theFile to (POSIX file (resource path of main bundle of me & "/myFile.jpg"))

tell application "Finder" to duplicate theFile to desktop as alias without replacing

Hope this helps…
j

Thanks so much! I knew there had to be a more elegant solution…mine was 8 lines long.