I have been trying many iterations to get this to work… can someone shed some light on how I might accomplish this? Thanks! I’m using OS 10.5.2
The actual code is more involved, but if this simple code snippet can be made to work, it would solve my problems!
The error message is "Can’t make file “Apollo:Users:bourne:Documents:DSSPlayer:Message:FolderA:dictation1” of application “System Events” into the expected type.
set folderList to {“~/Documents/DSSPlayer/Message/FolderA”, “~/Documents/DSSPlayer/Message/FolderB”}
set archiveFolder to “~/Documents/DSSPlayer/Message/Archive”
set curFolder to item 1 of folderList
tell application “System Events”
set dictationFiles to every file of folder curFolder
end tell
set currentDictation to item 1 of dictationFiles
tell application “Finder”
set name of file currentDictation to “name changed” --this is the part that gives an error message
move file currentDictation to archiveFolder
end tell
You’re using a Posix path and Sys Events or Finder want the HFS form.
additional to Adam’s statement,
System Events or the Finder returns class file, so omit file in the rename and move line
something like this, I created a relative path with path to documents folder
set DSSPlayerFolder to (path to documents folder as text) & "DSSPlayer:"
set folderList to {DSSPlayerFolder & "Message:FolderA:", DSSPlayerFolder & "Message:FolderB:"}
set archiveFolder to DSSPlayerFolder & "Message:Archive:"
set curFolder to item 1 of folderList
tell application "Finder"
set dictationFiles to every file of folder curFolder
set currentDictation to item 1 of dictationFiles
set name of currentDictation to "name changed" --this is the part that gives an error message
move currentDictation to folder archiveFolder
end tell
Thanks for the prompt replies!
Stefan, I implemented your script as written. It runs without reported error. However, it does not rename the file to “name changed”. It DOES move the file. Any ideas?
hm, on my machine it does rename the file,
the shell version should work anyway
set DSSPlayerFolder to (path to documents folder as text) & "DSSPlayer:"
set folderList to {DSSPlayerFolder & "Message:FolderA:", DSSPlayerFolder & "Message:FolderB:"}
set archiveFolder to DSSPlayerFolder & "Message:Archive:"
set curFolder to item 1 of folderList
tell application "Finder" to set dictationFiles to every file of folder curFolder
set currentDictation to POSIX path of (item 1 of dictationFiles as alias)
do shell script "mv " & quoted form of currentDictation & space & quoted form of (POSIX path of archiveFolder & "name changed")
Browser: Safari 523.15
Operating System: Mac OS X (10.5)
Works great! Thanks a million! I’ve literally spent hours trying different ways to make this work!
george