[zip]EPUB XLSX DOCX PPTX用 非圧縮ZIPアーカイブ
解凍したXLXSやPPTXのフォルダの画像に修正入れて戻す時用
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | # |
004 | (* |
005 | EPUB XLSX PPTX DOCX等 |
006 | 指定のフォルダから |
007 | 非圧縮のZIPでファイルを生成します |
008 | |
009 | *) |
010 | # com.cocolog-nifty.quicktimer.icefloe |
011 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
012 | use AppleScript version "2.8" |
013 | use framework "Foundation" |
014 | use scripting additions |
015 | |
016 | property refMe : a reference to current application |
017 | |
018 | |
019 | ###Wクリックで起動した場合 |
020 | on run |
021 | set aliasDefaultLocation to (path to desktop from user domain) as alias |
022 | set strPromptText to "フォルダをえらんでください\n非圧縮のZIPでファイルを生成します" as text |
023 | set strMesText to "フォルダをえらんでください\n非圧縮のZIPでファイルを生成します" as text |
024 | try |
025 | set listFolderPath to (choose folder strMesText with prompt strPromptText default location aliasDefaultLocation with multiple selections allowed, invisibles and showing package contents) as list |
026 | on error |
027 | log "エラーしました" |
028 | return "エラーしました" |
029 | end try |
030 | open listFolderPath |
031 | end run |
032 | |
033 | ###ドロップで起動した場合 |
034 | on open listFolderPath |
035 | tell application "Finder" |
036 | set strKind to (kind of (item 1 of listFolderPath)) as text |
037 | end tell |
038 | if strKind is not "フォルダ" then |
039 | return "フォルダ以外は処理しない" |
040 | end if |
041 | ####構造ファイルの名称を取得する |
042 | repeat with itemFolderPath in listFolderPath |
043 | set aliasFolderPath to itemFolderPath as alias |
044 | tell application "Finder" |
045 | tell folder aliasFolderPath |
046 | set listContentsAlias to name of every item as list |
047 | set strDirName to name as text |
048 | end tell |
049 | end tell |
050 | ####コマンドライン用に第一階層の項目をテキストにする |
051 | set strDirList to ("") as text |
052 | set strExtension to (missing value) |
053 | repeat with itemName in listContentsAlias |
054 | set strItemName to itemName as text |
055 | set strDirList to (strDirList & "\"" & strItemName & "\" ") as text |
056 | #拡張子判定 |
057 | if strItemName is "xl" then |
058 | set strExtension to "xlsx" as text |
059 | else if strItemName is "ppt" then |
060 | set strExtension to "pptx" as text |
061 | else if strItemName is "word" then |
062 | set strExtension to "docx" as text |
063 | else if strItemName is "OPS" then |
064 | set strExtension to "epub" as text |
065 | end if |
066 | end repeat |
067 | if strExtension = (missing value) then |
068 | return "フォルダの構造に誤りがあります" |
069 | end if |
070 | ### |
071 | #パス |
072 | tell application "Finder" |
073 | set aliasContainerDirPath to (container of aliasFolderPath) as alias |
074 | end tell |
075 | set strContainerDirPath to (POSIX path of aliasContainerDirPath) as text |
076 | set strDirPath to (POSIX path of aliasFolderPath) as text |
077 | #dot_clean実行 |
078 | set theComandText to ("/usr/sbin/dot_clean -n -m -v \"" & strDirPath & "\"") as text |
079 | do shell script theComandText |
080 | #FindeでDS_Storeを除去 |
081 | set theCmdCom to ("/usr/bin/find \"" & strDirPath & "\" -name \".DS_Store\" -depth -exec rm {} \\;") as text |
082 | do shell script theCmdCom |
083 | #移動 |
084 | set strCommandText to ("/usr/bin/cd \"" & strDirPath & "\"") as text |
085 | log strCommandText |
086 | do shell script strCommandText |
087 | #移動 |
088 | set strCommandText to ("pushd \"" & strDirPath & "\"") as text |
089 | log strCommandText |
090 | do shell script strCommandText |
091 | #圧縮実行 |
092 | set strCommandText to ("pushd \"" & strDirPath & "\" && '/usr/bin/zip' -rX \"../" & strDirName & "." & strExtension & "\" " & strDirList & "") as text |
093 | log "\r" & strCommandText & "\r" |
094 | do shell script strCommandText |
095 | |
096 | end repeat |
097 | |
098 | end open |
099 | |
100 | |
101 | |
102 | |
AppleScriptで生成しました |
| 固定リンク