Hi, I’m new, recent switcher (1year), on Os X.
I try to transpose the scripts i used in MCS system.
The problem, except that AppleScript Force me to relearn à new language, is, there is no problem.
My script Works. (Thx to Google, MacScripter, OsxHints, a co-worker, etc, etc…)
But i want to know if there some possibilities to improve the writting and maybee the fonctionnalities of my scripts.
This one is my first try.
--1- Set Var
--1.1- Choose Folder Where The Files Will Be Copied (VarName:BUFolder)
set BURootFolder to choose folder with prompt "Backup Folder"
--1.2- Set The Source Folder (VarName:VMFolder)
set VMFolder to ((path to home folder) as text) & "Documents:Virtual Machines:"
--1.3- Get The Date in %Y-%m-%d (ie:2008-01-17) (VarName:StrDate)
set myyear to year of (current date) as integer -- Retrieve Year
set mymonth to month of (current date) as integer -- Retrieve Month
set myday to day of (current date) as integer -- Retrieve Day
--1.3.1- Change the month if only 1 car length like February = 2 change to 02
set MonthLength to (length of (mymonth as text))
if MonthLength > 1 then
set StrDate to "VMware-" & myyear & "-" & mymonth & "-" & myday
else
set StrDate to "VMware-" & myyear & "-0" & mymonth & "-" & myday
end if
--2- Duplication
tell application "Finder"
--2.1- If Exists Destination Folder : Delete it
if exists folder ((BURootFolder & StrDate) as text) then
delete folder ((BURootFolder & StrDate) as text)
end if
--2.2- Create the Destination Folder with name VMware-" & StrDate (VMware-2008-02-2)
set BUFolder to make new folder at BURootFolder with properties {name:StrDate}
--2.3- Duplicate with ignoring timeout
ignoring application responses
set BA to duplicate every item in entire contents of (folder VMFolder) to BUFolder
end ignoring
end tell
So please comments and tell me what i did wrong and what’s ok.
Thx,
P
Model: MacBook2,1
AppleScript: 2.0
Browser: Safari 523.10.6
Operating System: Mac OS X (10.5)