forked from lksoft/MailMessageUUIDs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateInfoPlist.applescript
More file actions
65 lines (53 loc) · 1.79 KB
/
UpdateInfoPlist.applescript
File metadata and controls
65 lines (53 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
-- Use this script to insert the UUID list into an Info.pist file
property uuidListFileName : "SupportableUUIDList.txt"
property isTesting : false
on run argv
-- Ensure that we actually have the uuid text input file
tell application "Finder"
set scriptPath to path to me
set scriptFolder to container of scriptPath
end tell
set uuidInputFilePath to (scriptFolder as string) & uuidListFileName
if (not checkExistence(uuidInputFilePath)) then
log "The " & uuidListFileName & " file does not exist, so I cannot continue"
return 2
end if
-- Get the proper output file to use
if (isTesting) then
set infoPlistFilePath to (POSIX path of ((scriptFolder as string) & "testInfo.plist"))
else
-- Get the info plist file path from the arguments
if ((count of argv) > 0) then
set infoPlistFilePath to item 1 of argv
else
log "No Info.plist file path was given"
return 1
end if
end if
-- Try to remove all of the existing values, if there are any
try
do shell script "defaults delete " & quote & infoPlistFilePath & quote & " SupportedPluginCompatibilityUUIDs"
on error
-- Don't do anything
end try
-- Open the uuidList file
set theFile to open for access uuidInputFilePath
set theText to read theFile
close access theFile
set uuidValues to paragraphs of theText
-- Read in each line
repeat with aUUID in uuidValues
-- For each line that is not empty, add that to the array of the SupportedUUIDList in the InfoPlist file
if (length of aUUID is not 0) then
do shell script "defaults write " & quote & infoPlistFilePath & quote & " SupportedPluginCompatibilityUUIDs -array-add '" & aUUID & "'"
end if
end repeat
end run
on checkExistence(fileOrFolderToCheck)
try
alias fileOrFolderToCheck
return true
on error
return false
end try
end checkExistence