shell script and time

I’ve made a script to name a folder with the current date, using examples from these extremely helpful pages. I’d like to also add the time to the folder name, but can’t seem to get it to work. Any ideas ?

tell application “DropStuff” to open file “X”
tell application “Finder”
set file_location to “Y”
set file_name to "HES " & (do shell script “date +%d-%m-%y-%h”)
set file_alias to (“Y”) as alias
tell application “Finder”
set name of file_alias to file_name
end tell
end tell
tell application “Finder” to move file_alias to disk “zip 100” replacing yes

Is this OK?

set file_name to "HES " & (do shell script "date +%d-%m-%y-%h") & " " & (time string of (current date))

Result: “HES 13-05-04-May 7:43:08 AM”

You can do it all in the shell script (change the lowercase h to an uppercase H to get hours instead of the month name):

Jon

PS Carl, your solution returns a time string with colons in it and this is going to be used as a file name so that’s a no-go.


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Your original script has some other weird stuff in it (double tells, unused variables, etc.) here’s a streamlined version:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Gotcha.

Thanks for replying and yes, I know it is a bit messy, but I was having trouble with the syntax and it seemed to work.

The file that was created and named with the date/time will be copied to a external zip drive. This works fine, but retrieving it is harder. As the name of the file will be different every time, can I write a script that has a variable in it such as:

“if the file on the zip disk contains HES copy it to blah blah”

I can’t seem to get it to recognise a variable.

Thanks

WP