droplet for changing file name

In the amount of time I’ve searched for this script, I probably could have learned AppleScript. (Not really, I’ve tried in the past.)

I’m trying to find a droplet where when I would drop a file onto it, it would add the minutes and seconds to the file name. For instance, if I dopped a file called “report.html” on the droplet and the time was 7:51:49 AM, it would change it to the current time - “report5149.html” or “5149report.html”.

Is this an easy script to write? I thank anyone in advance who could help me.
Cindy

" I would drop a file onto it, it would add the minutes and seconds to the file name. For instance, if I dopped a file called “report.html” on the droplet and the time was 7:51:49 AM, it would change it to the current time - “report5149.html” or “5149report.html”.

File renaming has been my study lately, so I’m going to take this one on. The idea is possible, and the final script won’t be very intricate. But easy? There’s always something your going to miss, so give it a try but don’t expect easy.
Here’s what you’ll have to do:
On open the file, get the current date stamp.
Set the date stamp to a ‘string’
Set the name of the document to its current name and the date stamp.

On second thought I should have this done by 6pm. I’ll get back 2 you.
SiTCoM

You want the time added to the ‘existing name’ of the file, correct?

->You could have it so that you get to rename the file as well. That way if you end up with a document called ‘Gft_Aspec_Lame_filename456.html’ you could custom name it (the script would be able to keep the existing name as an option) to ‘11:53:27JacksReport.html’.

*Think about this: if you keep the existing filenames, eventually you might end up with files of the same name. ‘11:53:27report.html’ will happen twice a day if the file names are the same.That’s what you call a bug :!:

You also said the file would be ‘5327report.html’ (using my time example.) That’s minutes and seconds.

->Do you want the time or name to come first? What will be in the time field (hours, minutes, and/ or seconds?)

Get back to me on those two questions, otherwise I’m just tinkering.
SiTCoM

Yes!

Totally not necessary as I’ll be throwing them as soon as I get the data from the files.

Good point but will never happen in my case (as like I said before, I’ll be trashing the files as soon as I’ve finished with them, plus I’m never at work longer than 8 hours).

Whatever is easiest for you. If I had to choose, I’d prefer it after the name but before the prefix. But before the name is okay too. All I need is minutes and seconds so the file names differ in some way. So even if the script removed the original file name (report), that would be okay too.

THANK YOU!!

Cindy

I have complete control of the variables we talked about, so as you wish. I’m going to make it easy (on me) and simply name your files to what’s called thier “time string”. You’ll be able to drop one or up to 100 at a time, and thier names will be in the form of “9’37’43.html”. :smiley:

I’m going to build it and post it in ScriptBuilders for you to download as a working application ready to go. The script will stay open until you quit it, so that it doesn’t relaunch every time you use it.
I will post a link to it here that will be active in the next 24hrs.
Todd W.
SiTCoM

Hi,

I like to use the seconds after midnight as part of file naming. Using seconds, you don’t need to think about am/pm. Also, you can easily convert it back to time of a certain date. Something like this:

set cur_date to (current date)
set secs_time to (time of cur_date)
set secs_time_string to text -5 thru -1 of (“0000” & secs_time)
– change seconds time string back to date and time
set midnight_date to (date (date string of cur_date))
set date_and_time to midnight_date + (secs_time_string as integer)

This is good if you user doesn’t need to visually know what time the file was named.

gl,

http://scriptbuilders.net/success.php?id=2125

Hey Cindy- I made you the script because sometimes you want to learn apple script, and sometimes you just need the darn application!! I got the vibe from your post you’re ready to move on and get to work (Been there for sure). Someone always helps me here so I return the favors when I can.

The script was logical to work out, but ‘easy’ is in the eye of the scripter.
Here’s how it works:

Told applescript to learn the file extension so it could add it back when renaming
Told as to learn the date(that’s where the time is stored)
Told as to learn the time from the date
The date comes back like this “6:45:34 PM”<-Filenames shouldn’t have " : " in them
Told as to make the date into 6’45’34<-That’s the not so easy part
Told as to join the new time stamp 6’45’34 with the file extension (for example .html)
Got the result of a file named 6’45’34.html

That would be hard if you didn’t know at least an intermediate level of scripting.
Post back with questions or requests for tweaks to make it work.
“One day someone in here saved me a thousand key strokes”
SiTCoM

http://scriptbuilders.net/category.php?id=2125
There is the final resting place.

FilenameTimeX’ -Droplet that replaces name of file with the time stamp of the moment its dropped (4:45:37pm for example) in the form “4’45’37.ext”, ext being the file extension.

->Does not do mulitple files at once, to avoid duplicate file names (The script can process about 3 files a second).
SiTCoM

Todd,
This is absolutely perfect! Works flawlessly. I especially like how the script stays open.

You don’t know how much I appreciate the time you spent on this for me and hopefully others will find it as useful as I do.

Thanks again!!
Cindy

:smiley: :smiley: :smiley:

I’m glad I did this. I developed (with help in here!) a tool for renaming batches of files sorted by creation date. OS X lacks a “sort” command and I had experimented with setting file names to time stamps as a sort of “sort”. A much better solution came along but I kept the template anyway. That’s why it was so quick.

I like the idea of stamping date, time, or both into filenames as an option. After doing this, I think I’m going to add the option into my filenaming script for date stamping.

Let me know if it needs adjustments after you’ve used it, or any other applications you may need.
SC