1 -----------------------------------------------------------------------------
2 -- Name: docs/mac/M5mcp2xml.applescript
3 -- Purpose: Automatic export of CodeWarrior 5 projects to XML files
4 -- Author: Gilles Depeyrot
8 -- Copyright: (c) 2001 Gilles Depeyrot
9 -- Licence: wxWindows licence
10 -----------------------------------------------------------------------------
12 -- This AppleScript automatically recurses through the selected folder looking for
13 -- and exporting CodeWarrior projects to xml files.
14 -- To use this script, simply open it with the 'Script Editor' and run it.
18 -- Suffix used to recognize CodeWarrior project files
20 property gProjectSuffix : "M5.mcp"
23 -- Project and build success count
25 set theProjectCount to 0
26 set theProjectSuccessCount to 0
29 -- Ask the user to select the wxWindows samples folder
31 set theFolder to choose folder with prompt "Select the wxWindows folder"
33 ExportProjects(theFolder)
35 tell me to display dialog "Exported " & theProjectSuccessCount & " projects out of " & theProjectCount
40 on ExportProjects(inFolder)
41 global theProjectCount, theProjectSuccessCount
43 tell application "Finder" to update inFolder
46 tell application "Finder" to set theProject to ((the first file of inFolder whose name ends with gProjectSuffix) as string)
51 if theProject is not "" then
52 set theProjectCount to theProjectCount + 1
54 -- save the current text delimiters
55 set theDelimiters to my text item delimiters
57 -- replace the ".mcp" extension with ".xml"
58 set my text item delimiters to "."
59 set theList to (every text item of theProject)
60 set theList to (items 1 thru -2 of theList)
61 set theExport to (theList as string) & ".xml"
63 -- restore the text delimiters
64 set my text item delimiters to theDelimiters
66 tell application "CodeWarrior IDE 4.0.4"
68 -- Open the project in CodeWarrior
72 -- Export the selected project
75 export project document 1 in theExport
76 set theProjectSuccessCount to theProjectSuccessCount + 1
77 on error number errnum
78 tell me to display dialog "Error " & errnum & " exporting " & theExport
87 tell application "Finder" to set theSubFolders to every folder of inFolder whose name does not end with " Data"
88 repeat with theFolder in theSubFolders
89 ExportProjects(theFolder)