Append Current Date To File Name in Bike.app

How do I modify this script to make a new Bike document named " name & current date"?

-- get a date-as-text:
set d to (current date)
set d to short date string of d & space & time string of d

-- add it to any name:
make document with properties {name:"that name" & space & d}
2 Likes

@alastor933
@Fredrik71
Thank you for your date solution help for this, It’s much appreciated.

For cases when you don’t need to reuse bits of current date:

tell (current date) to ¬
   set dateTimeStr to short date string & space & time string

Now then – if you want full control over your date-time string:

--------------------------------------------------------
# Auth: Christopher Stone { Heavy-lifting by Shane Stanley }
# dCre: 2014/01/19 09:46 +1100
# dMod: 2023/01/19 20:39 -0600
# Appl: AppleScriptObjC
# Task: Create a date-string using ICU Date-Time Format Syntax (Mojave+)
#     : http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @AppleScriptObjC, @ASObjC, @Shane, @Formatted, @Date, @String
--------------------------------------------------------
use AppleScript version "2.7" -- macOS 10.14 Mojave
use framework "Foundation"
use scripting additions
--------------------------------------------------------

my formatDate:(current date) usingFormat:"y-dd-MM HH:mm" -- 24h time

--------------------------------------------------------
--» HANDLERS
--------------------------------------------------------
on formatDate:theDate usingFormat:formatString
   set theFormatter to current application's NSDateFormatter's new()
   theFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"en_US_POSIX")
   theFormatter's setDateFormat:formatString
   set theString to theFormatter's stringFromDate:theDate
   return theString as text
end formatDate:usingFormat:
--------------------------------------------------------
1 Like