Applescript time
The Applescript line
set the date_stamp to ((the current date) as string)
yields me the date in long form.
How do I get the date in short form - ie something like 20-7-11?
If you're working with file paths, you should be careful; short date string uses slashes, which can confuse the file system since POSIX uses slashes as directory delimiters. you might want to modify the slashes into hyphens, using something like the following:
set ds to tid(tid(short date string of (current date), "/"), "-")
on tid(input, delim)
set {oldTID, my text item delimiters} to {my text item delimiters, delim}
if class of input is list then
set output to input as text
else
set output to text items of input
end if
set my text item delimiters to oldTID
return output
end tid
Similar Messages
-
How would I tell Applescript to set iChat's status as the time until 11pm tonight.
For example, if it was 1:45:00p.m. now, my status would read "9hrs 15min 0s until party"
I want it to repeat every second so that it counts down by seconds.
Thanks a lot.Then, post to the AppleScript forum under OS X Technologies. However, don't expect anyone to provide you with the script. For that, you'll need to show some initiative and read one of the many books available, Apple's site at http://www.apple.com/applescript/index.html, or the Language guide at http://www.apple.com/applescript/features/features.html#1002
-
What is the script language I need before a script I have.... to set the time for the script to run and where does the script need to be stored so it will execute at the set time?
The script will run after the mac wakes and before a backup runs, if that matters
Good references on scripting for dummies appreciated
Many thanks01. Decide where you intend to save your code as a '.scpt' file. For example in '/Documents/crontab/' (you will have to create the 'crontab' folder. You may have to first create the '/Documents/' folder).
In this example I will assume you are going to save as 'myASCode.scpt' in the '/Documents/crontab/' folder.
02. Launch 'Terminal', in the '/Applications/Utilities/' folder.
03. At the prompt - enter ...
crontab -e
... then press ...
i
... to enter the 'insert mode'. Next enter ...
58 01 * * * osascript /Documents/crontab/myASCode.scpt
... then press ...
<control> C
... to exit 'insert mode'. Next, enter ...
:wq
... and press the <return> key.
04. You may now quit 'Terminal'.
As a result, every day at 01.58 the script 'myASCode.scpt' will be executed.
To learn more about crontab -
01. Do a 'crontab' Google or equivalent search.
02. Via 'Terminal', enter ...
man crontab
... pressing (over and over, until you hear the beep) the space bar, to view the complete manual for 'crontab'.
To exit the manual, press the 'q' key (to return to the prompt). -
How to run Excel 2011 from applescript for batch
Every night at 2:00am, I want to convert an Excel spreadsheet to CSV. I'm doing this on a Mac, with Excel 2011. The following Applescript works sometimes:
tell application "Microsoft Excel"
open "/Users/siemsen/PetesLookup/BPO.inventory.current.xls"
save active workbook in "BPO.inventory.current.csv" as CSV file format
close workbook 1 saving no
quit
end tell
With the above script saved in a file named convert.scpt, I can execute it from a bash script using the command "osascript convert.scpt". The bash script runs in a launchd job at 2:00am every day.
It works if Excel is already running on the Mac at the time the cron job runs. If not, it starts Excel, which insists on displaynig a "Excel Workbook Gallery" dialog box. No one is present on the Mac at the time, so no one clicks on the "Cancel" in the dialog box, so the Applescript times out and the cron job fails.
How do I get around this? Can I somehow start Excel without the **** "Excel Workbook Gallery" dialog? Is there some other trick that will allow the job to run unattended?In Excel preferences (general tab) uncheck the checkbox that says "Open Project Gallery when application opens". that should remove the startup dialog.
-
I have a script that uses URL Access to upload a file. The script works fine except lately the AppleEvent has been timing out. At first I thought this was from the server being down but, I could always access the server through FTP. Now I am wondering if this could be a port problem. Has anyone else ran into this problem? Does anyone know what ports URL Access uses?
PowerBook G4 1Ghz Mac OS X (10.2.x)Without knowing more about your script it's very hard to tell, but the fact you say it times out might be relevant.
Are you uploading large files? What's your bandwidth limit?
Is it possible that the file is so large and/or your bandwidth limited so it's taking too long for URL Access Scripting to complete the upload, so AppleScript times out thinking it's hung?
One thing to try would be wrapping the commands in a 'with timeout' block, like:
with timeout of 600 seconds
tell application "URL Access Scripting"
-- your commands here
end tell
end timeout
Now AppleScript will wait up to 10 minutes for URL Access Scripting to do its thing before timing out. -
AppleScript - How do I make multiple dialogs display at the same time?
Is it possible to make more than one dialog be displayed at one time with AppleScript? Thanks in advance.
You can see what is available in the Standard Additions dictionary. There are a (very) few things you can fake, but AppleScript dialogs are designed for simple feedback.
-
Cannot set view time in Calendar via Applescript
I use the AppleScript below in an application to capture the weekly calendar view. I would swear, under an OS release before 10.9.5, this would cause the the Calendar view to be set with the top line at 7am of the current day. Now, the Calendar view ignores the time setting. Can anyone suggest whether this is a bug and/or provide a workaround?
TIA
set daytoshow to (current date)
set the time of daytoshow to 60 * 60 * 7
tell application "Calendar"
activate
view calendar at daytoshow
switch view to week view
set the visible of the first window to true
end tellYour wife could publish her MobileMe Calendar and then you could subscribe to it on your iPhone.
-
AppleScript PhotoShop Resize Times Out?
Hi all,
I've found what seems to be a pretty decent image resize applescript to use with photoshop cs3, but every time I try to use it, it just hangs on the sizing image dialog box. Anybody have any suggestions?
tell application "Adobe Photoshop CS3"
activate
-- set parameters
set my_files to choose file with prompt "Choose some files" default location (path to desktop) with multiple selections allowed
set destination_folder to choose folder with prompt "Choose destination folder" default location (path to desktop)
set destination_path to destination_folder as string
set sizeofthumbnail to text returned of (display dialog "Set size of thumbnail" default answer "100")
set sizeofthumbnail to sizeofthumbnail as integer
set output_quality to text returned of (display dialog "Set quality of final output" default answer "60")
set output_quality to output_quality as integer
-- for each file
repeat with my_file in my_files
set original_extension to name extension of (info for my_file)
open my_file showing dialogs never
set my_doc to the current document
set original_name to the name of my_doc
set doc_width to width of my_doc
set doc_height to height of my_doc
if doc_width > doc_height then
set new_width to sizeofthumbnail
set new_height to round (doc_height * (new_width / doc_width))
else
set new_height to sizeofthumbnail
set new_width to round (doc_width * (new_height / doc_height))
end if
resize image my_doc width new_width height new_height resample method bicubic sharper
tell current document
export in live_folder as save for web with options {class:save for web export options, web format:JPEG, quality:target_quality}
close saving no
end tell
end repeat
end tell
-- finishing touches
tell application "Finder"
activate
open folder destination_folder
beep
end tellI commented out the export line (I don't have CS3, only an old version of CS) and it seems to work fine. the problem, then, is with the export line, and (at a guess) the issue might be the odd way you've specified the document. instead of using the export command in a document tell block, try 'export current document in live_folder as...' and see if that helps.
-
Add applescript date/time output to Automator email Subject
I'm having a big issue with this new forum format (which is awful IMHO) but thats not my problem at hand...
My problem is getting the output of an AppleScript to show the correct time in a Lion (+latest patches) new Mail subject line.
This is the "Run AppleScript" action (working fine)
on run {input, parameters}
set FutureDate to (current date) + (6 * days)
set FutureDate2 to date "11:00:00" of FutureDate
return FutureDate2
end run
This is "View Results" action (output as expected - during testing),
{date "Saturday, 1 September 2012 11:00:00"}
The "Set Value of Variable" action (has been set to, without marks),
Variable: <NextSaturday>
This is "View Results" Action output (still looking good - during testing),
{date "Saturday, 1 September 2012 11:00:00"}
And in the "New Mail Message" action (the rest of email not shown),
Subject = <NextSaturday> @ The Park
This should deliver a nice output in the actual new Mail message, however the Subject line time is now incorrectly shown....
Subject = 2012-09-01 10:00:00 +0000 @ The Park
I have tried this without the second "View Results" Action (part of fault finding) yet still have the same problem. Sending with the <Current time> Variable works correctly, meaning it probably has something to do with the Date/Time preferences in Lion; located in the UK but on BST at the moment.
Maybe I am missing something but after quite a bit of reading this should be possible, but I cannot understand how to overcome this issue.
All help gratefully receieved.It does look like an issue with coercing an AppleScript date object to an ISO date string - you can just coerce the date to text in your Run AppleScript action. The way you set the time gives an error on my machine (note that as of AppleScript 2.1, a date string must exactly match one of the system date formats), it should be something like:
set FutureDate to (current date) + (6 * days)
set time of FutureDate to (11 * hours)
return FutureDate as text -
How to fetch current system time in milliseconds using AppleScript?
I need to write the actual systemtime hh:mm:ss.msc into a field of FileMaker by using AppleScript (as FileMaker does still not support TimeStamps down to milli seconds) - now, how to realize that?
Any help is welcome - ThanxHi Mathur,
kindly help me in mapping a field in which I have to map current system time.
I think there is no standard function for time like the date so do i write a UDF for the same or any other way an in case a UDF than please help in that.
Mathur no need to write UDF for that..
Use standard function Current date-------> In that (Target Format) u have to specify the time i.e: HHmmss
Thats it..... Noe use this function as u like...
Satya Kumar -
Why does Safari open every time I open AppleScript
Every time I simply open (not run) a certain AppleScript, Safari opens(it is not told to do so unless the program runs, which it isnt)
ps - I am somewhat experienced with AppleScript, so I know that Im not doing anything to make it run the script
thanks youI see it has stopped, but if the Safari Dictionary was open when you quit Applescript Editor, it will open the Dictionary when it opens, thus opening Safari.
But, if you didn't have the Safari Dictionary open, I don't know what was going on. -
I am attempting to take a path item that is on its own layer and change its color multiple times, saving it each time.
I was able to do it with javascript however can't get it to work in applescript.
Javascript:
(Items are already selected that I intend to change.)
var iL = app.activeDocument.pathItems.length;
var colorSwatches = app.activeDocument.swatchGroups.getByName('newColors');
var allColors = colorSwatches.getAllSwatches();
var colorNames = Array();
for (var i = 0; i < allColors.length; i++){
colorNames.push(allColors[i].name);
for (x = 0; x<colorNames.length; x++)
var currentColor = allColors[x].name;
for (i=0; i<iL; i++)
var myItem = app.activeDocument.pathItems[i];
if(myItem.selected)
myItem.fillColor = app.activeDocument.swatches.getByName(currentColor).color;
(I then go on to save each one)
When trying to cross over into applescript I have the following so far:
set iL to count every path item of document 1
set colorSwatches to swatchgroup "newColors" of current document
set allColors to get all swatches colorSwatches
set swatchCount to count every item in allColors
repeat with i from 1 to swatchCount
set currentSwatch to item i of allColors
repeat with x from 1 to iL
set myItem to path item i of document 1
here is where I have no idea what I am doing... I can't figure out how to test if an item is selected
if myItem's has selected artwork is equal to true then
set fill color of myItem to {swatch:currentSwatch}
end if
end repeat
end repeat
Or better yet is there a way I can select every path item of a layer and change its color that way?
Something like the following:
set fill color of every path item of layer "art" of document 1 to {swatch:currentSwatch}
Thanks for any input!I'm throwing it into a Applescript OBJc project I am working with. I currently have it in a javascript file within the actual project however this is the slowest part of my project and I'm going to attempt to speed it up some.
Let's say I'm changing the color of a path item 35 times... this starts to eat a ton of time up.
My applescript save illustrator file as jpeg is much faster than the javascript one for some reason...
It's also something I have needed to do numerous times in the past and never got around to asking. -
Use Applescript In Xcode To Make Timer In Window
Hi Everyone, I Making An Applescript and cocoa App In Xcode, and i need a Timer that is embedded in a interface builder window how do i do this?
One way would be to create a countdown handler using performSelector:withObject:afterDelay: to repeatedly count down, putting the current value into your text field. For example, using countdownText as your text field and countdownTime as the value to count down:
on countdown()
set countdownTime to countdownTime - 1
if countdownTime is less than 0 then -- clear timer and reset
parent's cancelPreviousPerformRequestsWithTarget_selector_object_(me, "countdown", missing value)
countdownText's setStringValue_("") -- clear the countdown text
-- reset countdownTime value and do whatever when countdown ends
else -- do it again
countdownText's setStringValue_(countdownTime) -- update the countdown text
performSelector_withObject_afterDelay_("countdown", missing value, 1.0)
end if
end countdown -
Automator or Applescript to turn Time Machine on/off
When Time Machine is copying, Final Cut Pro turns into a very enoying beach ball party
Is there a way to write an Automator / Applescript that turns Time Machine off when I start FCP. And turn it back on when I close the app?
As of now, I manually stop Time Machine when I Start FCP. But it's easy to forget to turn it back on...
/STime Machine Editor will allow you to set up and schedule backups to occur whenever you like.
You might want to take a look:
TimeMachineEditor - Time Software - Free -
Applescript called by plist on specific time interval through launchd
Hey all
I'm hoping someone out there has learned something useful about launchd, plist's, and timing scripts.
I have a rather simple script that I was trying to make run on a schedule through launchd (15 min to be exact) mainly to get to learn the system.
The general problems... I finally got through it all enough to load the script into launchd through a valid plist ("verified in Lingon" though I don't think was necessary since all Lingon did was add fields withe "false" values). The jist though is the plist file (I've named com.nathan.messagealert.plist to keep the *^#4& formatting going) calls on an Applescript (which runs perfectly fine in the editor or even as an app on startup) which it should then run on a "StartInterval" schedule of 900 sec. Now, I read and found the proper way of making the script an executable file which made it load but it's acting very funny. Remember the time schedule of 15 min I mentioned?? Well, when the script was loaded it kept running and running and running...you get the idea. It wouldn't stop until I killed it.
Any thoughts on why this would react this way? Is a scpt file ok? Does the scpt need a "quit" or "exit" at the end of it? I'm just analyzing the possibilities...
Here's the Applescript .scpt file which has no other properties than being a scpt at the moment (it is not run only, or app, etc.)
[CODE]say "Welcome back, Nathan."
tell application "Mail"
repeat with thisAccount in every account
set thisInBox to mailbox named "INBOX" of thisAccount
set thisUnreadCount to unread count of thisInBox
if thisUnreadCount is not 0 then
set unreadMessages to (messages of thisInBox whose read status is false)
if thisUnreadCount > 1 then
set pluralText to "s"
set verbText to "are"
else
set pluralText to ""
set verbText to "is"
end if
set speechCountText to "There " & verbText & " " & thisUnreadCount & " unread message" & pluralText & " in " & (name of thisAccount) & "."
say speechCountText
tell application "Safari"
activate
end tell
end if
end repeat
end tell[/CODE]
And here is the plist file which calls it
[CODE]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>com.nathan.messagealert</string>
<key>OnDemand</key>
<false/>
<key>Program</key>
<string>/usr/bin/osascript</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Library/Scripts/MailMessage.scpt</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>StartInterval</key>
<integer>1200</integer>
</dict>
</plist>[/CODE]
Again, any input on why this would cause the script to run over and over and over would be greatly appreciated. ThanksI would suggest that you make the plist using lingon which can easily create one that does a simple job like that. at the very least get rid of the entries
Keep Alive , On Demand and Run at load. why do you have them at all?
The Keep alive one might be what's causing this even though it's set to false.
and why does it still have a disabled key set to true?
Maybe you are looking for
-
Regain hard drive space after deleting partition
Hello all, I had a lot of issues after updating to Snow Leopard so I ended up doing a clean install of SL rather than the update to fix all the issues. It works great now with no lag or any issues of the sort. However I was following a tutorial on ho
-
Spinning ball when i address email
i'm getting the spinning beach ball when i address a new email address or more than one email. other than that, email is working fine. it was slow in the past and i changed to port server 587.
-
Designing in SSRS( Begining Qty field)
Hello, I need help on how to create a field. This is the scenario. There is a table containing transaction list as thus; Item number: Hace Date Doc num Qty Cost Amount Bal 2/5/12 345 6 6
-
My ipad is frozen.It says not enough storage but when I press the settings, it's still not moving or doing anything. What do I need to do?
-
Dear SAPTechies, We are planning to bring in ACC 7.2 to our non production environment (HP UNIX). On analysis found that the managed systems are supported since 4.6C but can anybody tell that what is the supported oracle database versions for those m