It works great.
I made a few changes to make it work with my existing shell script. I'm sending this over Apple Remote Desktop so the AS is contained in the osascript block.
My original shell command for renaming the folder is commented out for reference.
myDate=`eval date +%m%d%y`
# mv "/Users/ladmin/Desktop/IMAGED ON - " "/Users/ladmin/Desktop/IMAGED ON - $myDate"
osascript <<EndOfMyScript
set itemLoc to
POSIX file "/Users/ladmin/Desktop" as
alias
set itemName to "IMAGED ON - "
set newName to
itemName & "$myDate"
tell application "Finder"
activate
try
set
itemAlias to (item
itemName of itemLoc)
as alias
on error
beep
return
-- itemAlias does not exist
end try
-- change other attributes of itemAlias here
set
name of the result to
newName -- do this last
end tell
EndOfMyScript
Jeff
On May 29, 2013, at 1:32 PM, Jeff Hanlon wrote:
Is there a way to retain the position by using an applescript or some
additional bash command?
I tried this simple AppleScript …
set itemLoc to
path to desktop
set itemName to "untitled folder"
set newName to "New Folder Name"
tell application "Finder"
activate
try
setitemAlias
to (itemitemName
of itemLoc) as alias
on error
beep
return-- itemAlias does not exist
end try
-- change other attributes of itemAlias here
set
name of the result tonewName
-- do this last
end tell
It worked with no problem. My experience is that changing the name should be done last
if you are changing attributes other than the name.