Hi
How can the following code be changed so that the year is stored with 4 positions (2006)?
set todaysdate to do shell script “date "+%d.%m.%y"”
Thanks and regards
Lazybaer
Hi
How can the following code be changed so that the year is stored with 4 positions (2006)?
set todaysdate to do shell script “date "+%d.%m.%y"”
Thanks and regards
Lazybaer
Replace “y” with cap “Y”
Some other variants of are.
set TodaysDateA to do shell script "date \"+%d-%m-%Y\""
set TodaysDateB to do shell script "date \"+%d-%m-%y\""
set TodaysDateC to do shell script "date \"+%a-%b-%Y\""
set TodaysDateD to do shell script "date \"+%A-%B-%Y\""
set TodaysTime to do shell script "date \"+%T\""
can be quicker than tidying string.
Hi Mark
Thanks for a fast answer. Everything works now perfectly.
Lazybaer
If you do want to include time with this these may be better without the “:” seperaters
-- Date as dd-mm-yyyy
set TodaysDateA to do shell script "date \"+%d-%m-%Y\""
-- Date as dd-mm-yy
set TodaysDateB to do shell script "date \"+%d-%m-%y\""
-- Date as short dd-mm-yyyy
set TodaysDateC to do shell script "date \"+%a-%b-%Y\""
-- Date as long dd-mm-yyyy
set TodaysDateD to do shell script "date \"+%A-%B-%Y\""
-- time as 24 hour clock
set TodaysTime24 to do shell script "date \"+%k-%M-%S\""
-- time as 12 hour clock
set TodaysTime12 to do shell script "date \"+%l-%M-%S-%p\""
A handy little utility that I found some time back to help editing some shell stuff can still be got for free at
http://www.bruji.com/bwana/index.html
May be worth a look. Loads the man pages into your browser.
Mark;
I used Bwana for man files too, until Nigel Garvey (with some small additions I made) wrote the script below. As you will see, it not only gets the man pages for display as pdf files, but saves them as you go. Then each time you invoke it, it looks for a saved version (fast) or goes to the shell for a paged it doesn’t have and saves it. This turns out to be faster than bwana, so I always use it myself, and I suspect Nigel does too. The thread for this is in Code Exchange (didn’t track it down),
on main()
set theCommand to ""
repeat while theCommand is ""
display dialog "View man page for this command:" default answer theCommand
set theCommand to text returned of result
end repeat
try
set manFolderPath to (path to documents folder as Unicode text) & "Unix 'man' Pages (PDFs):"
set manFile to manFolderPath & theCommand & "-ManPage.pdf"
tell application "Finder"
if exists manFile then
open manFile
return
end if
end tell
do shell script ("mkdir -p " & quoted form of POSIX path of manFolderPath)
set manFilePath to quoted form of POSIX path of manFile
do shell script "/usr/bin/man -t " & quoted form of theCommand & " | /usr/bin/pstopdf -i -o " & manFilePath & "; open -a /Applications/Preview.app " & manFilePath
on error errorMsg number errorNum
display alert "Error " & errorNum message errorMsg buttons "Cancel" default button 1
end try
end main
main()
tell application "Script Debugger 4" to activate -- or whatever you use; Smile, Script Editor
Thanks very much adam you can never have too many tools in the box. That will come in useful. Both faster and more elegant. Had to change “display alert” to “display dialog” to get it to compile why would that be?
Because you’re running Panther? display alert came along in Tiger, I think.
Adam
That is what I was thinking too. Not a problem though. A cool solution none the less liking it a lot already.
“Display alert” will work in Studio/Xcode 1.5 under 10.3.9, but not Script Editor.