[mobileconfig] PayloadVersionを今日の日付に変更する
バージョン管理用(私は日付管理が好き)
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
property refMe : a reference to current application
on run
set aliasDefaultLocation to (path to desktop from user domain) as alias
set listUTI to {"com.apple.mobileconfig"} as list
set strPromptText to "ファイルをえらんでください" as text
set strMesText to "ファイルをえらんでください" as text
try
set listFilePath to (choose file strMesText with prompt strPromptText default location aliasDefaultLocation of type listUTI with invisibles and multiple selections allowed without showing package contents) as list
on error
log "エラーしました"
return "エラーしました"
end try
open listFilePath
end run
on open listFilePath
set strDateno to doGetDateNo("yyyyMMdd")
set ocidVerSionNo to (refMe's NSNumber's numberWithInteger:strDateno)'s intValue
log strDateno
repeat with itemFilePath in listFilePath
set aliasFilePath to itemFilePath as alias
set strFilePath to (POSIX path of aliasFilePath) as text
set ocidFilePathStr to (refMe's NSString's stringWithString:strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false)
##############################################
## 本処理 ROOT 項目
##############################################
set ocidPlistDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
set listReadPlistData to (refMe's NSMutableDictionary's dictionaryWithContentsOfURL:ocidFilePathURL |error|:(reference))
set ocidReadDict to (item 1 of listReadPlistData)
(ocidPlistDict's setDictionary:ocidReadDict)
set numVerSion to (ocidPlistDict's valueForKey:"PayloadVersion") as integer
log "現在のバージョン:" & numVerSion
###変更
(ocidPlistDict's setValue:ocidVerSionNo forKey:"PayloadVersion")
set numVerSion to (ocidPlistDict's valueForKey:"PayloadVersion") as integer
log "変更後のバージョン:" & numVerSion
##############################################
## 本処理 PayloadContent
##############################################
set ocidPayloadContentArray to (ocidPlistDict's objectForKey:"PayloadContent")
repeat with itemPayloadContentArray in ocidPayloadContentArray
set numVerSion to (itemPayloadContentArray's valueForKey:"PayloadVersion") as integer
log "現在のバージョン:" & numVerSion
###変更
(itemPayloadContentArray's setValue:ocidVerSionNo forKey:"PayloadVersion")
set numVerSion to (itemPayloadContentArray's valueForKey:"PayloadVersion") as integer
log "変更後のバージョン:" & numVerSion
end repeat
##############################################
## 保存
##############################################
set ocidPlistType to refMe's NSPropertyListXMLFormat_v1_0
set listPlistEditDataArray to (refMe's NSPropertyListSerialization's dataWithPropertyList:ocidPlistDict format:ocidPlistType options:0 |error|:(reference))
set ocidPlisSaveData to item 1 of listPlistEditDataArray
set boolSaveDone to (ocidPlisSaveData's writeToURL:ocidFilePathURL options:(refMe's NSDataWritingAtomic) |error|:(reference))
log boolSaveDone as list
end repeat
end open
to doGetDateNo(strDateFormat)
####日付情報の取得
set ocidDate to current application's NSDate's |date|()
###日付のフォーマットを定義
set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init()
ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX")
ocidNSDateFormatter's setDateFormat:strDateFormat
set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
set strDateAndTime to ocidDateAndTime as text
return strDateAndTime
end doGetDateNo
| 固定リンク
「Admin Mobileconfig」カテゴリの記事
- 【メモ】MDMでイマイチまだ理解が足りない部分(2025.01.11)
- [mobileconfig]言語設定の変更(非推奨)(2024.12.20)
- mobileconfigを使って言語設定を切り替える(2024.12.16)
- [The Unarchiver] mobileconfigの値を見直した(2024.12.06)
- [NSGlobalDomain_m]AppleLanguages(2024.11.27)
「Admin Device Management」カテゴリの記事
- デバイスUUIDの取得(2024.11.11)
- モデル名を取得する(2024.05.17)
- TB Default Item Identifiers(com.apple.finder.plist)(2023.12.22)
- [profiles] profiles コマンド書き出したバックアップを各ファイルに書き出す(2023.11.12)
- [profiles]現在のユーザー・プロファイル設定をバックアップ(2023.10.31)