For example, if my username is jir107, I’m logged in as jir107, when I drop a file named “application.doc” into a folder it will get renamed to “jir107_application.doc” Does anybody know how I can do this in Applescript? Thanks!
Model: MacBook
Browser: Firefox 2.0
Operating System: Mac OS X (10.4)
Here is a simple droplet. Save it as an application and drop the files onto it.
the script takes always the short user name of the current user.
Renaming a file using a folder action causes an infinitive loop in the hot folder itself.
on run
display dialog "Drop files or folders onto the icon to rename them" buttons {"OK"} default button 1
end run
on open theseFiles
set userName to short user name of (system info)
repeat with oneFile in theseFiles
tell application "Finder" to set name of oneFile to (userName & "_" & (get name of oneFile))
end repeat
end open
this is similar to one of the problems that I am trying to solve, maybe you can help me too. I want to rename the files based upon a file name in an excel (or text file) list. I can organize the list to have the desired filename in one column and the path/location of the current file which I would like renamed in another column.
Assuming the new file names in the first column and the HFS(!) paths in the second, try this
set excelFile to choose file with prompt "Choose the Excel file" of type {"XLS6", "XLS7", "XLS8"}
tell application "Microsoft Excel"
open excelFile
set P to value of used range of active sheet
end tell
repeat with i in P
tell application "Finder" to set name of file (item 2 of i) to item 1 of i
end repeat
Any chance you can solve this one too. It requires knowledge of Entourage. I have a list of outgoing mail that has already been created using email merge. I would like to attach the files that I just renamed thereto.
set excelFile to choose file with prompt "Choose the Excel file" of type {"XLS6", "XLS7", "XLS8"}
tell application "Microsoft Excel"
open excelFile
set P to value of used range of active sheet
end tell
repeat with i in P
set theFile to item 2 of i as alias
tell application "Finder" to set name of theFile to item 1 of i
tell application "Microsoft Entourage"
activate
try
set myMessage to make new outgoing message with properties ¬
{to recipients:"john@doe.com", subject:"Send File ", attachment:theFile}
open myMessage
end try
end tell
end repeat
It worked and you provided me with everything that most people would need to tweak it, but I am limited. This created a new message. I think there may be two solutions. Add the text that I already added to the email to this script or (preferred) figure out a way to have the script locate the outgoing message. I put the source code (from entourage) from the message that was created using the script you provided and the source code from one of the messages in the outbox. I don’t know if this will help.
outbox message
It also appears that the Message-ID: are in sequential order and would line up with the excel list. the only thing that changes are the last two numbers “39” to 40" etc. Message-ID: <C3D9DFA3.35A%john@anywhere.net>