Renaming a file through applescript

HI!

I’m trying to have applescript automatically rename a file which is currently selected in finder and have it renamed with the Ethernet Address in it.

I can’t figure it out! help!


tell application "System Events" to tell property list file (preferences folder's path & "ByHost:com.apple.screensaver." & words of (system info)'s primary Ethernet address & ".plist")
	set value of property list item "modulePath" to "/System/Library/Screen Savers/Abstract.slideSaver"
	set value of property list item "moduleName" to "Abstract"
end tell
 

this applescript code I got somewhere on the net to automatically set the screensaver. I need to get that ethernet address into the current selected finder file thorugh applescript. any ideas?


tell application "Finder"
	set selectedItem to selection
	set new_item_name to "1"
	set the name of file selectedItem to new_item_name
end tell

I tried this simple rename but get and error of “Can’t make {document file … “Users” of startup disk} into type integer.”

(I cut down the error code but the problem is the type integer.

thanks!

Hi,

welcome to MacScripter :slight_smile:

I guess you’re working with OS X, then you better post into the OS X forum (this is OS 9)

this renames the first of the selected files with the Ethernet MAC address


set MACaddress to (do shell script "ifconfig en0 ether | awk '/ether/ {print $2}' | tr -d ':'")
tell application "Finder" to set name of item 1 of (get selection) to MACaddress

oops! didn’t notice that. thanks for the help! worked like a charm!