QuickTime

スクリーンレーコーディング(画面収録)のテンポラリーフォルダの中に残ったファイルをゴミ箱に移動します


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# スクリーンレコーディングのテンポラリーディレクトリの
005# エイリアスをMoviesフォルダ内に作成します
006# 画面収録 スクリーンレコーディングのキャッシュで
007# 残ってしまったジャンクムービーファイルをゴミ箱に入れます
008#com.cocolog-nifty.quicktimer.icefloe
009----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
010use AppleScript version "2.8"
011use framework "Foundation"
012use framework "AppKit"
013use scripting additions
014
015property refMe : a reference to current application
016set appFileManager to refMe's NSFileManager's defaultManager()
017######
018#元
019set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
020set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
021set ocidScreenRecordingsDirURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("Group Containers/group.com.apple.screencapture/ScreenRecordings") isDirectory:(true)
022######
023#先
024set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSMoviesDirectory) inDomains:(refMe's NSUserDomainMask))
025set ocidMoviesDirPathURL to ocidURLsArray's firstObject()
026set ocidBookMarkPathURL to ocidMoviesDirPathURL's URLByAppendingPathComponent:("ScreenRecordings") isDirectory:(false)
027
028######
029#BoookMark取得
030set ocidKeysArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
031ocidKeysArray's addObject:(refMe's NSURLCustomIconKey)
032set ocidOption to (refMe's NSURLBookmarkCreationSuitableForBookmarkFile)
033set listDone to (ocidScreenRecordingsDirURL's bookmarkDataWithOptions:(ocidOption) includingResourceValuesForKeys:(ocidKeysArray) relativeToURL:(missing value) |error| :(reference))
034set ocdiBookMarkData to (item 1 of listDone)
035
036
037######
038#エイリアス作成
039set ocidOption to (refMe's NSURLBookmarkCreationSuitableForBookmarkFile)
040set listResults to (refMe's NSURL's writeBookmarkData:(ocdiBookMarkData) toURL:(ocidBookMarkPathURL) options:(ocidOption) |error| :(reference))
041
042
043######
044#エイリアスをロック
045set ocidTargetPath to ocidBookMarkPathURL's |path|()
046set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
047ocidAttrDict's setValue:(true) forKey:(refMe's NSFileImmutable)
048set listDone to appFileManager's setAttributes:(ocidAttrDict) ofItemAtPath:(ocidTargetPath) |error| :(reference)
049
050######
051#コンテンツの収集
052set ocidOption to (refMe's NSDirectoryEnumerationSkipsHiddenFiles)
053set ocidKeyArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
054ocidKeyArray's addObject:(refMe's NSURLPathKey)
055set listResponse to (appFileManager's contentsOfDirectoryAtURL:(ocidScreenRecordingsDirURL) includingPropertiesForKeys:(ocidKeyArray) options:(ocidOption) |error| :(reference))
056set ocidSubPathURLArray to (item 1 of listResponse)
057
058######
059#ゴミ箱へ入れる
060repeat with itemURL in ocidSubPathURLArray
061  
062  set listDone to (appFileManager's trashItemAtURL:(itemURL) resultingItemURL:(missing value) |error| :(reference))
063  if (item 2 of listDone) ≠ (missing value) then
064    set strErrorNO to (item 2 of listDone)'s code() as text
065    set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
066    refMe's NSLog("■:" & strErrorNO & strErrorMes)
067    return "エラーしました" & strErrorNO & strErrorMes
068  end if
069end repeat
070
AppleScriptで生成しました

|

[QuickTimePlayer]サブモニタにウィンドウに移動する(考え中)

OpenできるファイルのみOpenする

【スクリプトエディタで開く】|

#!/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 framework "AppKIt"
use scripting additions
property refMe : a reference to current application

property strBundleID : "com.apple.QuickTimePlayerX"

on run
  ###対応UTIを取得
  set listUTI to doGetUTI()
  ###ダイアログ
  set aliasDefaultLocation to (path to desktop from user domain) as alias
  set strPromptText to "ファイルをえらんでください"
  set strMesText to "ファイルををえらんでください"
  try
    set listFilePath to (choose file strMesText with prompt strPromptText default location aliasDefaultLocation of type listUTI with multiple selections allowed, invisibles and showing package contents) as list
  on error
    log "エラーしました"
return "エラーしました"
  end try
open listFilePath
end run



on open listFilePath
  set listOpenFilePath to {} as list
  repeat with itemFilePath in listFilePath
    set aliasFilePath to itemFilePath as alias
    set objInfoFor to info for aliasFilePath
    ###ドロップされたファイルのUTI
    set strUTI to (type identifier of objInfoFor) as text
    ###アプリケーションの対応UTIを収集して
    set listUTI to doGetUTI()
    ###対象アプリケーションで開く事ができるファイルのみ別リストにする
    if listUTI contains strUTI then
      set end of listOpenFilePath to (aliasFilePath)
    end if
  end repeat
  
  
  ###スクリーン
  set ocidScreenArray to refMe's NSScreen's screens()
  set numCntScreen to ocidScreenArray's |count|()
  ###メインモニタ
  set ocidMainScreen to refMe's NSScreen's mainScreen()
  set ocidMainScreenName to ocidMainScreen's localizedName()
  set strMainScreenName to ocidMainScreenName as text
  
  if numCntScreen > 1 then
    ###サブモニタ
    set ocidSubMoniter to ocidScreenArray's lastObject()
    set ocidScreenName to ocidSubMoniter's localizedName()
    set strScreenName to ocidScreenName as text
    set strMenuName to ("" & strScreenName & "に移動") as text
  end if
  log strMainScreenName
  log strScreenName
  
  
  tell application id strBundleID
    set numCntWindow to (count of every window) as integer
    if numCntWindow ≥ 1 then
      tell every window
close saving no
      end tell
    end if
  end tell
  
  repeat with itemOpenFilePath in listOpenFilePath
    set aliasFilePath to itemOpenFilePath as alias
    tell application id strBundleID
      open file aliasFilePath
    end tell
    tell application "QuickTime Player"
      tell application "System Events"
tell front desktop
log display name as text
end tell
tell process "QuickTime Player"
set frontmost to true
tell menu bar 1
click menu bar item "ウインドウ"
delay 0.2
tell menu "ウインドウ"
click menu item strMenuName
delay 0.2
end tell
end tell
keystroke return
end tell
      end tell
    end tell
  end repeat
  
end open


to doGetUTI()
  ###アプリケーションのURLを取得
  ###NSバンドルをUTIから取得
  set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:(strBundleID)
  if ocidAppBundle = (missing value) then
    ###NSバンドル取得できなかった場合
    set appNSWorkspace to refMe's NSWorkspace's sharedWorkspace()
    set ocidAppPathURL to appNSWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID)
  else
    set ocidAppPathURL to ocidAppBundle's bundleURL()
  end if
  ###Plistのパス
  set ocidPlistPathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/Info.plist") isDirectory:false
  set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidPlistPathURL)
  set ocidDocTypeArray to ocidPlistDict's objectForKey:"CFBundleDocumentTypes"
  if ocidDocTypeArray = (missing value) then
    set strOutPutText to "missing value" as text
  else
    ####リストにする
    set listUTl to {} as list
    ###対応ドキュメントタイプをリストにしていく
    repeat with itemDocTypeArray in ocidDocTypeArray
      set listContentTypes to (itemDocTypeArray's objectForKey:"LSItemContentTypes")
      if listContentTypes = (missing value) then
###拡張子の指定のみの場合
set ocidExtension to (itemDocTypeArray's objectForKey:"CFBundleTypeExtensions")
set strClassName to ocidExtension's className() as text
repeat with itemExtension in ocidExtension
set strExtension to itemExtension as text
set ocidContentTypes to (refMe's UTType's typeWithFilenameExtension:(strExtension))
set strContentTypes to ocidContentTypes's identifier() as text
set strContentTypes to ("" & strContentTypes & "") as text
set end of listUTl to (strContentTypes)
end repeat
      else
repeat with itemContentTypes in listContentTypes
set strContentTypes to ("" & itemContentTypes & "") as text
set end of listUTl to (strContentTypes)
end repeat
      end if
    end repeat
  end if
return listUTl
end doGetUTI

|

[screencapture]画面キャプチャー QuickTimeウィンドウ

【スクリプトエディタで開く】

#!/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 framework "AppKit"
use framework "Quartz"
use scripting additions

property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()

set numMakeImage to 20 as integer

###起動
tell application "QuickTime Player" to launch

###起動確認 最大10秒
repeat 10 times
  tell application "QuickTime Player"
    set boolFrontMost to frontmost as boolean
    if boolFrontMost is false then
      activate
    else
      exit repeat
    end if
  end tell
end repeat

####ウィンドチェック
tell application "QuickTime Player"
  set numCntWindow to (count of every window) as integer
end tell
if numCntWindow = 0 then
  return "ウィンドウがありません"
end if

####ファイル名用に今の時間
tell application "QuickTime Player"
  tell front document
    set numSec to (current time) as integer
    set aliasFilePath to its file as alias
    set numFullSec to its duration as integer
    set listDimension to its natural dimensions as list
  end tell
  tell front window
    set listNewBounds to {0, 25, (item 1 of listDimension), (item 2 of listDimension)} as list
    set its bounds to listNewBounds
  end tell
end tell


####ファイル名用に今の時間
tell application "QuickTime Player"
  tell front window
    set numWindowID to its id as integer
  end tell
end tell

################################
##### パス関連
################################
###開いているファイル
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
set ocidFileName to ocidFilePathURL's lastPathComponent()
set strFileName to ocidFileName as text
####コンテナディレクトリ
set ocidContainerDirURL to ocidFilePathURL's URLByDeletingLastPathComponent()
set strSaveDirName to (strFileName & "._Images") as text
set ocidSaveDirPathURL to ocidContainerDirURL's URLByAppendingPathComponent:strSaveDirName isDirectory:true
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(missing value) |error|:(reference)

################################
##### 本処理
################################
set numTimeInterval to (numFullSec / numMakeImage) as integer

set numSetTime to 60 as integer

###マウスカーソルを画面の外に
###移動させたい位置(左上が0x0
set ocidNSpoint to refMe's NSMakePoint(0, 0)

repeat numMakeImage times
  ####ファイル名
  set strSaveFileName to (strFileName & "." & numSetTime & ".tiff") as text
  set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:strSaveFileName isDirectory:false
  set strSaveFilePath to ocidSaveFilePathURL's |path| as text
  ##キャプチャ前にカーソル位置を確認
  ###カーソルを画面外へ移動
  refMe's CGWarpMouseCursorPosition(ocidNSpoint)
  tell application "QuickTime Player"
    tell front document
      set current time to numSetTime
      delay 0.5
    end tell
  end tell
  set strCommandText to "/usr/sbin/screencapture -a -x -w -o -r -t tiff -T 0 -l " & numWindowID & " \"" & strSaveFilePath & "\"" as text
  do shell script strCommandText
  delay 0.5
  
  ###カウントアップ
  set numSetTime to numSetTime + numTimeInterval as integer
end repeat


|

[QuickTime]時間で切り出す

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSURL : a reference to refMe's NSURL

###ffmpeg へのパス
set strPathToFFMPEG to "echo $HOME/bin/ffmpeg/ffmpeg" as text
set strBinPath to (do shell script strPathToFFMPEG)


tell current application
activate
display alert "QuickTime Player" message "開始ポジションを選んでください" as informational giving up after 60
end tell

tell application "QuickTime Player"
set objMovieRef to a reference to the front document
set aliasFilePath to file of objMovieRef as alias
end tell



set strFilePath to (POSIX path of aliasFilePath) as text
####NSStringパスにします
set ocidFilePath to (refNSString's stringWithString:strFilePath)
###NSURLにしたら
set ocidFilePathURL to (refNSURL's alloc()'s initFileURLWithPath:ocidFilePath)
####ファイル名を取得
set ocidFileName to ocidFilePathURL's lastPathComponent()
-->(*NSPathStore2*)
####拡張子を取得
set ocidFileExtension to ocidFilePathURL's pathExtension()
-->(*NSPathStore2*)
####ファイル名から拡張子を取っていわゆるベースファイル名を取得
set ocidPrefixName to ocidFileName's stringByDeletingPathExtension
####コンテナディレクトリを取得
set ocidContainerDirURL to ocidFilePathURL's URLByDeletingLastPathComponent()
####AVAssetに格納して
set ocidReadAsset to (refMe's AVURLAsset's alloc()'s initWithURL:ocidFilePathURL options:(missing value))
####AVAssetのビデオトラックを取り出します
set ocidReadAssetArray to (ocidReadAsset's tracksWithMediaType:(refMe's AVMediaTypeVideo))
set ocidAssetVideoTrack to (ocidReadAssetArray's objectAtIndex:0)
###ビデオの縦横幅
set ocidBounds to ocidAssetVideoTrack's naturalSize()
set numDimensionsW to width of ocidBounds as integer
set numDimensionsH to height of ocidBounds as integer
set strDimensionsW to numDimensionsW as text
set strDimensionsH to numDimensionsH as text
####フレームレートFPS
set numFrameRate to (ocidAssetVideoTrack's nominalFrameRate()) as number

tell application "QuickTime Player"
set objMovieRef to a reference to the front document
set numDuration to the duration of objMovieRef
tell document 1
activate
properties
set numStartDuration to current time as number
set numStartTimeH to round of (numStartDuration / 3600) rounding down
set numStartTimeHH to numStartTimeH * 3600 as integer
if numStartTimeHH > 3600 then
set numStartTimeMM to numStartDuration - numStartTimeHH as number
else
set numStartTimeMM to numStartDuration as number
end if
--> numStartTimeHが時間
-->残りであるnumStartTimeMMが残りの秒数
set numStartTimeM to round of (numStartTimeMM / 60) rounding down
set numStartTimeSS to numStartTimeM * 60 as integer
set numStartTimeS to numStartTimeMM - numStartTimeSS as integer
end tell
end tell

####ゼロパディング
set strStartTimeH to (text -2 through -1 of ("00" & numStartTimeH)) as text
set strStartTimeM to (text -2 through -1 of ("00" & numStartTimeM)) as text
set strStartTimeS to (text -2 through -1 of ("00" & numStartTimeS)) as text

set strStartTime to ("" & strStartTimeH & ":" & strStartTimeM & ":" & strStartTimeS & "") as text
set strStartTimeFileName to ("" & strStartTimeH & "_" & strStartTimeM & "_" & strStartTimeS & "") as text
log strStartTime



tell current application
activate
display alert "QuickTime Player" message "終了ポジションを選んでください" as informational giving up after 60
end tell

tell application "QuickTime Player"
set objMovieRef to a reference to the front document
set numDuration to the duration of objMovieRef
tell document 1
activate
properties
set numEndTimeDuration to current time as number
set numEndTimeH to round of (numEndTimeDuration / 3600) rounding down
set numEndTimeHH to numEndTimeH * 3600 as integer
if numStartTimeHH > 3600 then
set numEndTimeMM to numEndTimeDuration - numEndTimeHH as number
else
set numEndTimeMM to numEndTimeDuration as number
end if
--> numEndTimeHが時間
-->残りであるnumEndTimeMMが残りの秒数
set numEndTimeM to round of (numEndTimeMM / 60) rounding down
set numEndTimeSS to numEndTimeM * 60 as integer
set numEndTimeS to numEndTimeMM - numEndTimeSS as integer
end tell
end tell

####ゼロパディング
set strEndTimeH to (text -2 through -1 of ("00" & numEndTimeH)) as text
set strEndTimeM to (text -2 through -1 of ("00" & numEndTimeM)) as text
set strEndTimeS to (text -2 through -1 of ("00" & numEndTimeS)) as text

set strEndTime to ("" & strEndTimeH & ":" & strEndTimeM & ":" & strEndTimeS & "") as text
set strEndTimeFileName to ("" & strEndTimeH & "_" & strEndTimeM & "_" & strEndTimeS & "") as text

log strStartTime
log strEndTime
log numFrameRate

set strNewFilePath to strFilePath & "." & strStartTimeFileName & "x" & strEndTimeFileName & ".mp4"



set strComandText to "'" & strBinPath & "' -i '" & strFilePath & "' -ss " & strStartTime & " -to " & strEndTime & " -vcodec libx264 -acodec copy '" & strNewFilePath & "'" as text


tell application "Terminal"
launch
activate
set objWindowID to (do script "\n\n")
delay 1
###コマンド実行
do script strComandText in objWindowID

do script "\n\n" in objWindowID
end tell

|

[QuickTime]current timeを時間表記にする

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSURL : a reference to refMe's NSURL


tell current application
activate
display alert "QuickTime Player" message "開始ポジションを選んでください" as informational giving up after 60
end tell

tell application "QuickTime Player"
set objMovieRef to a reference to the front document
set aliasFilePath to file of objMovieRef as alias
end tell



set strFilePath to (POSIX path of aliasFilePath) as text
####NSStringパスにします
set ocidFilePath to (refNSString's stringWithString:strFilePath)
###NSURLにしたら
set ocidFilePathURL to (refNSURL's alloc()'s initFileURLWithPath:ocidFilePath)
####ファイル名を取得
set ocidFileName to ocidFilePathURL's lastPathComponent()
-->(*NSPathStore2*)
####拡張子を取得
set ocidFileExtension to ocidFilePathURL's pathExtension()
-->(*NSPathStore2*)
####ファイル名から拡張子を取っていわゆるベースファイル名を取得
set ocidPrefixName to ocidFileName's stringByDeletingPathExtension
####コンテナディレクトリを取得
set ocidContainerDirURL to ocidFilePathURL's URLByDeletingLastPathComponent()
####AVAssetに格納して
set ocidReadAsset to (refMe's AVURLAsset's alloc()'s initWithURL:ocidFilePathURL options:(missing value))
####AVAssetのビデオトラックを取り出します
set ocidReadAssetArray to (ocidReadAsset's tracksWithMediaType:(refMe's AVMediaTypeVideo))
set ocidAssetVideoTrack to (ocidReadAssetArray's objectAtIndex:0)
###ビデオの縦横幅
set ocidBounds to ocidAssetVideoTrack's naturalSize()
set numDimensionsW to width of ocidBounds as integer
set numDimensionsH to height of ocidBounds as integer
set strDimensionsW to numDimensionsW as text
set strDimensionsH to numDimensionsH as text
####フレームレートFPS
set numFrameRate to (ocidAssetVideoTrack's nominalFrameRate()) as number

tell application "QuickTime Player"
set objMovieRef to a reference to the front document
set numDuration to the duration of objMovieRef
tell document 1
activate
properties
set numStartDuration to current time as number
set numStartTimeH to round of (numStartDuration / 3600) rounding down
set numStartTimeHH to numStartTimeH * 3600 as integer
if numStartTimeHH > 3600 then
set numStartTimeMM to numStartDuration - numStartTimeHH as number
else
set numStartTimeMM to numStartDuration as number
end if
--> numStartTimeHが時間
-->残りであるnumStartTimeMMが残りの秒数
set numStartTimeM to round of (numStartTimeMM / 60) rounding down
set numStartTimeSS to numStartTimeM * 60 as integer
set numStartTimeS to numStartTimeMM - numStartTimeSS as integer
end tell
end tell

####ゼロパディング
set strStartTimeH to (text -2 through -1 of ("00" & numStartTimeH)) as text
set strStartTimeM to (text -2 through -1 of ("00" & numStartTimeM)) as text
set strStartTimeS to (text -2 through -1 of ("00" & numStartTimeS)) as text

set strStartTime to ("" & strStartTimeH & ":" & strStartTimeM & ":" & strStartTimeS & "") as text
set strStartTimeFileName to ("" & strStartTimeH & "_" & strStartTimeM & "_" & strStartTimeS & "") as text
log strStartTime



tell current application
activate
display alert "QuickTime Player" message "終了ポジションを選んでください" as informational giving up after 60
end tell

tell application "QuickTime Player"
set objMovieRef to a reference to the front document
set numDuration to the duration of objMovieRef
tell document 1
activate
properties
set numEndTimeDuration to current time as number
set numEndTimeH to round of (numEndTimeDuration / 3600) rounding down
set numEndTimeHH to numEndTimeH * 3600 as integer
if numStartTimeHH > 3600 then
set numEndTimeMM to numEndTimeDuration - numEndTimeHH as number
else
set numEndTimeMM to numEndTimeDuration as number
end if
--> numEndTimeHが時間
-->残りであるnumEndTimeMMが残りの秒数
set numEndTimeM to round of (numEndTimeMM / 60) rounding down
set numEndTimeSS to numEndTimeM * 60 as integer
set numEndTimeS to numEndTimeMM - numEndTimeSS as integer
end tell
end tell

####ゼロパディング
set strEndTimeH to (text -2 through -1 of ("00" & numEndTimeH)) as text
set strEndTimeM to (text -2 through -1 of ("00" & numEndTimeM)) as text
set strEndTimeS to (text -2 through -1 of ("00" & numEndTimeS)) as text

set strEndTime to ("" & strEndTimeH & ":" & strEndTimeM & ":" & strEndTimeS & "") as text
set strEndTimeFileName to ("" & strEndTimeH & "_" & strEndTimeM & "_" & strEndTimeS & "") as text

log strStartTime
log strEndTime
log numFrameRate

|

[QuickTime]ビデオファイル名変更 横px 縦px FPS 追加

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions



property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSURL : a reference to refMe's NSURL
property refNSMutableString : a reference to refMe's NSMutableString
property refNSMutableArray : a reference to refMe's NSMutableArray


property refNSArray : a reference to refMe's NSArray
property refAVURLAsset : a reference to refMe's AVURLAsset
property refAVMediaTypeVideo : a reference to refMe's AVMediaTypeVideo



property listUTI : {"com.apple.quicktime-movie", "public.mpeg-4", "public.mpeg-2-transport-stream"}


on run
######ログ表示
doLogView()
####NSFileManager初期化
set objFileManager to refMe's NSFileManager's alloc()'s init()
log className() of objFileManager as text
####ダウンロードディレクトリ
set ocidUserDownloadsPath to (objFileManager's URLsForDirectory:(refMe's NSDownloadsDirectory) inDomains:(refMe's NSUserDomainMask))
log ocidUserDownloadsPath as list
log className() of ocidUserDownloadsPath as text
###ダウンロードディレクトリ
set ocidUserDownloadsPath to ocidUserDownloadsPath's objectAtIndex:0
log ocidUserDownloadsPath as text
log className() of ocidUserDownloadsPath as text
###
set aliasDefaultLocation to ocidUserDownloadsPath as alias
log aliasDefaultLocation as alias
log class of aliasDefaultLocation

###複数選択可能なダイアログを出す--> 戻り値はリストで格納されます
set listChooseFileAliasList to (choose file with prompt "ムービーファイルを選んでください" default location aliasDefaultLocation of type listUTI with invisibles and multiple selections allowed without showing package contents) as list
open listChooseFileAliasList

####NSFileManager解放
objFileManager's release()
end run


on open listChooseFileAliasList
####NSFileManager初期化
set objFileManager to refMe's NSFileManager's alloc()'s init()
log className() of objFileManager as text

repeat with objFile in listChooseFileAliasList
###UNIXパス
set aliasFilePath to objFile as alias
set strFilePath to POSIX path of objFile

##Make NSString
set ocidFilePath to (refNSString's stringWithString:strFilePath)
log ocidFilePath as text
log className() of ocidFilePath as text

if strFilePath contains "~" then
set ocidPosixPath to refNSString's stringByExpandingTildeInPath()
log ocidPosixPath as text
log className() of ocidPosixPath as text
end if
#####NSURL
set ocidURLPath to (refNSURL's fileURLWithPath:ocidFilePath)
log ocidURLPath as text
log ocidURLPath's className() as text
#####URLByDeletingLastPathComponent Dir
set ocidURLContainerDirPath to ocidURLPath's URLByDeletingLastPathComponent()
log ocidURLContainerDirPath as text
log className() of ocidURLContainerDirPath as text
#####URLByDeletingLastPathComponent Dir
set strURLContainerDirPath to ocidURLContainerDirPath's relativePath()
log strURLContainerDirPath as text
log className() of strURLContainerDirPath as text
#####lastPathComponent
set ocidFileName to ocidURLPath's lastPathComponent()
log ocidFileName as text
log className() of ocidFileName as text
#####pathExtension
set ocidPathExtension to ocidURLPath's pathExtension()
log ocidPathExtension as text
log className() of ocidPathExtension as text

########ファイル名からカンマを取る
######Arrayの初期化
set ocidMutableArray to (refNSMutableArray's alloc()'s initWithCapacity:0)
log ocidMutableArray as list
log className() of ocidMutableArray as text
###カンマを定義
set ocidNSCFCharacterSet to (refMe's NSCharacterSet's characterSetWithCharactersInString:".")
log className() of ocidNSCFCharacterSet as text
###ocidNSCFCharacterSetArray=リスト化
set ocidMutableArray to (ocidFileName's componentsSeparatedByCharactersInSet:ocidNSCFCharacterSet)
log ocidMutableArray as list
log className() of ocidMutableArray as text
###リストをテキストに
set ocidShortFileName to (ocidMutableArray's objectAtIndex:0)
log ocidShortFileName as text
log className() of ocidShortFileName as text


############確認用にログ出します
log "###Input"
log "Alias: " & aliasFilePath as text
log "POSIX: " & strFilePath as text
log "alias Container" & ocidURLContainerDirPath as text
log "POSIX Container" & strURLContainerDirPath as text
log "FileName: " & ocidFileName as text
log "Extension: " & ocidPathExtension as text
log "ShortFileName: " & ocidShortFileName as text


####AVURLAsset取得
set ocidAVURLAsset to (refAVURLAsset's alloc()'s initWithURL:ocidURLPath options:(missing value))
log className() of ocidAVURLAsset as text
####AVURLAssetのビデオ部分を取得
set ocidVideoAssetTrack to (ocidAVURLAsset's tracksWithMediaType:(refAVMediaTypeVideo))
log className() of ocidVideoAssetTrack as text
####取得したビデオトラック(Arrayで入るので)の最初のトラック
set ocidAsset to (ocidVideoAssetTrack's objectAtIndex:0)
log ocidAsset as list
log className() of ocidAsset as text
####サイズ
set ocidBounds to ocidAsset's naturalSize()
log ocidBounds as record
log class of ocidBounds as text

set numDimensionsW to width of ocidBounds as integer
set numDimensionsH to height of ocidBounds as integer
set strDimensionsW to numDimensionsW as text
set strDimensionsH to numDimensionsH as text
####フレームレートFPS
set ocidFrameRate to ocidAsset's nominalFrameRate()
log ocidFrameRate as real
log class of ocidFrameRate as text
####整数にしてテキスト化
##set strFPS to (ocidFrameRate as integer) as text
set strFPS to ocidFrameRate as text
###################小数点以下がある場合は2桁に整形
if strFPS contains "." then
####NSDecimalNumber
set ocidDecimalNumber to (refMe's NSDecimalNumber's decimalNumberWithString:strFPS)
log ocidDecimalNumber as text
log className() of ocidDecimalNumber as text

###NSNumberFormatterの初期化
set ocidNSNumberFormatter to refMe's NSNumberFormatter's alloc()'s init()
log ocidNSNumberFormatter
log className() of ocidNSNumberFormatter as text
###小数点以下2桁のフォーマット
(ocidNSNumberFormatter's setPositiveFormat:"##0.00")
####フォーマットを適応
set ocidDecimalNumber to (ocidNSNumberFormatter's stringFromNumber:ocidDecimalNumber)
log ocidDecimalNumber as text
log className() of ocidDecimalNumber as text
set strFPS to ocidDecimalNumber as text
ocidNSNumberFormatter's release()
end if
log "###VideoInfo"
log "W: " & strDimensionsW
log "H: " & strDimensionsH
log "FPS: " & strFPS


#####変更後のファイル名
set strNewFileName to ((ocidShortFileName as text) & "." & strDimensionsW & "x" & strDimensionsH & "." & strFPS & "fps.mov") as text
#####変更後のファイルパス
set strNewFilePath to ((strURLContainerDirPath as text) & "/" & strNewFileName) as text

log "###OutPut"
log "AliasOutPutDir: " & ocidURLContainerDirPath
log "NewFileName: " & strNewFileName
log "NewFilePath: " & strNewFilePath

#####保存先のdファイルパス
set ocidDistFilePath to (refNSString's stringWithString:strNewFilePath)
###ファイルパスに同名のファイルがあるか?
set boolFileExists to (objFileManager's fileExistsAtPath:ocidDistFilePath isDirectory:false)
log boolFileExists
###同名のファイルがある場合は1をつける
if boolFileExists is true then
#####変更後のファイル名
set strNewFileName to (strShortFileName & "." & strDimensionsW & "x" & strDimensionsH & "." & strFPS & "fps.1.mov") as text
#####変更後のファイルパス
set strNewFilePath to (strContainerDirPath & strNewFileName) as text
####リネーム後のファイルパスをNSString
set ocidDistFilePath to (refNSString's stringWithString:strNewFilePath)
end if

tell application "QuickTime Player"
####ファイルをオープンしてobjOpenDocに格納
set objOpenDoc to open file aliasFilePath
tell objOpenDoc
#####書き出し
##export the front document in (POSIX file strNewFilePath) using settings preset "1080p"
##export the front document in (POSIX file strNewFilePath) using settings preset "720p"
##export the front document in (POSIX file strNewFilePath) using settings preset "480p"
export objOpenDoc in (POSIX file strNewFilePath) using settings preset "4K"

##export the front document in (POSIX file strNewFilePath) using settings preset "Audio Only"
end tell
###ファイルを閉じる
close objOpenDoc
end tell

####解放
ocidAVURLAsset's release()
ocidVideoAssetTrack's release()
objFileManager's release()
end repeat

####NSFileManager解放
objFileManager's release()
end open





#########################ログ表示
on doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[QuickTime]書き出し (その2)FPS入り

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions



property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL
property objNSArray : a reference to objMe's NSArray
property objAVURLAsset : a reference to objMe's AVURLAsset
property objAVMediaTypeVideo : a reference to objMe's AVMediaTypeVideo

property objNSNotFound : a reference to 9.22337203685477E+18 + 5807


property listUTI : {"com.apple.quicktime-movie", "public.mpeg-4", "public.mpeg-2-transport-stream"}



on run
######ログ表示
doLogView()
###選択ダイアログのデフォルトパス
tell application "Finder"
set aliasDefaultLocation to (path to desktop folder from user domain) as alias
log aliasDefaultLocation as alias
end tell
###複数選択可能なダイアログを出す--> 戻り値はリストで格納されます
set listChooseFile to (choose file with prompt "ムービーファイルを選んでください" default location aliasDefaultLocation of type listUTI with invisibles and multiple selections allowed without showing package contents) as list
log listChooseFile as list
open listChooseFile
end run


on open listChooseFile

log "DDD" & listChooseFile
###listChooseFileに入ってるエリアス分だけ繰り返す
repeat with objFile in listChooseFile
############まずは、ファイルパス関連を取得
###UNIXパス
set strFilePath to POSIX path of objFile as text
####ファイルエイリアス
set aliasFilePath to objFile as alias
####ファイルのコンテナ(ファイルのあるディレクトリ)のエイリアス
tell application "Finder"
set aliasContainerDirPath to container of aliasFilePath as alias
end tell
###ファイルのあるコンテナのユニックスパス
set strContainerDirPath to POSIX path of aliasContainerDirPath as text

############ファイル名と拡張子
tell application "Finder"
####ファイルINFOを取得
set objInfo to info for objFile
####ファイル名
set strFileName to name of objInfo as text
####拡張子名
set strExtension to name extension of objInfo as text
end tell
#####ファイル名から拡張子を取り除く(UNIXBasename)
set AppleScript's text item delimiters to "."
set listFileName to every text item of strFileName
set AppleScript's text item delimiters to ""
set numCntDot to (count of listFileName) as number
set strShortFileName to (item 1 of listFileName) as text

############確認用にログ出します
log "###Input"
log "Alias: " & aliasFilePath as text
log "POSIX: " & strFilePath as text
log "alias Container" & aliasContainerDirPath as text
log "POSIX Container" & strContainerDirPath as text
log "FileName: " & strFileName as text
log "Extension: " & strExtension as text
log "ShortFileName: " & strShortFileName as text
####################
##NSURL
set ocidNSURL to (objNSURL's fileURLWithPath:strFilePath)
log className() of ocidNSURL as text

####AVURLAsset取得
set ocidAVURLAsset to (objMe's AVURLAsset's alloc()'s initWithURL:ocidNSURL options:(missing value))
log className() of ocidAVURLAsset as text

####AVURLAssetのビデオ部分を取得
set ocidVideoAssetTrack to (ocidAVURLAsset's tracksWithMediaType:(objMe's AVMediaTypeVideo))
log className() of ocidVideoAssetTrack as text

####取得したビデオトラック(Arrayで入るので)の最初のトラック
set ocidAsset to (ocidVideoAssetTrack's objectAtIndex:0)
log ocidAsset as list
log className() of ocidAsset as text

####サイズ
set ocidBounds to ocidAsset's naturalSize()
log ocidBounds as record
log class of ocidBounds as text

set numDimensionsW to width of ocidBounds as integer
set numDimensionsH to height of ocidBounds as integer
set strDimensionsW to numDimensionsW as text
set strDimensionsH to numDimensionsH as text

####フレームレートFPS
set ocidFrameRate to ocidAsset's nominalFrameRate()
log ocidFrameRate as real
log class of ocidFrameRate as text

####整数にしてテキスト化
##set strFPS to (ocidFrameRate as integer) as text
set strFPS to ocidFrameRate as text
log strFPS

###################小数点以下がある場合は2桁に整形
if strFPS contains "." then
####NSDecimalNumber
set ocidDecimalNumber to (objMe's NSDecimalNumber's decimalNumberWithString:strFPS)
log ocidDecimalNumber as text
log className() of ocidDecimalNumber as text

###NSNumberFormatterの初期化
set ocidNSNumberFormatter to objMe's NSNumberFormatter's alloc()'s init()
log ocidNSNumberFormatter
log className() of ocidNSNumberFormatter as text
###小数点以下2桁のフォーマット
(ocidNSNumberFormatter's setPositiveFormat:"##0.00")
####フォーマットを適応
set ocidDecimalNumber to (ocidNSNumberFormatter's stringFromNumber:ocidDecimalNumber)
log ocidDecimalNumber as text
log className() of ocidDecimalNumber as text
set strFPS to ocidDecimalNumber as text
end if
###################

#####変更後のファイル名
set strNewFileName to (strShortFileName & "." & strDimensionsW & "x" & strDimensionsH & "." & strFPS & "fps.mov") as text
#####変更後のファイルパス
set strNewFilePath to (strContainerDirPath & strNewFileName) as text
log "###OutPut"
log "AliasOutPutDir: " & aliasContainerDirPath
log "NewFileName: " & strNewFileName
log "NewFilePath: " & strNewFilePath

####################同名のファイルの有無を確認
#####NSFileManager定義
set objFileManager to objMe's NSFileManager's defaultManager()
#####保存先のdファイルパス
set ocidDistFilePath to (objNSString's stringWithString:strNewFilePath)
###ファイルパスに同名のファイルがあるか?
set boolFileExists to (objFileManager's fileExistsAtPath:ocidDistFilePath isDirectory:false)
log boolFileExists
###同名のファイルがある場合は1をつける
if boolFileExists is true then
#####変更後のファイル名
set strNewFileName to (strShortFileName & "." & strDimensionsW & "x" & strDimensionsH & "." & strFPS & "fps.1.mov") as text
#####変更後のファイルパス
set strNewFilePath to (strContainerDirPath & strNewFileName) as text
####リネーム後のファイルパスをNSString
set ocidDistFilePath to (objNSString's stringWithString:strNewFilePath)
end if



tell application "QuickTime Player"
####ファイルをオープンしてobjOpenDocに格納
set objOpenDoc to open file aliasFilePath
tell objOpenDoc
#####書き出し
##export the front document in (POSIX file strNewFilePath) using settings preset "1080p"
##export the front document in (POSIX file strNewFilePath) using settings preset "720p"
##export the front document in (POSIX file strNewFilePath) using settings preset "480p"
export objOpenDoc in (POSIX file strNewFilePath) using settings preset "4K"

##export the front document in (POSIX file strNewFilePath) using settings preset "Audio Only"
end tell
###ファイルを閉じる
close objOpenDoc
end tell

end repeat




end open




#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[QuickTime]"書き出しの進行状況"を開く

"書き出しの進行状況"

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSNotFound : a reference to 9.22337203685477E+18 + 5807

###おまじない
tell application "System Events"
launch
activate
end tell



tell application "QuickTime Player"
###書き出しWINDOWの有無
set numChkProgressWindow to 0 as number
###QuickTime Playerを前面に
activate
####開いているWINDOWをリストに
set listEveryWindow to every window
log listEveryWindow as list
###ウィンドウの数を数えて
set numCntWindow to count listEveryWindow
log numCntWindow as number
###本来ならこれでようたりるはずなんだけど
if numCntWindow = 0 then
activate
tell application "System Events"
tell process "QuickTime Player"
keystroke "p" using {option down, command down}
end tell
end tell
set numChkProgressWindow to 1 as number
end if
###ウィンドウが1以上なら
if numCntWindow1 then
repeat numCntWindow times
###ウィンドウの名前を取得して
set strWindowName to name of item numCntWindow of listEveryWindow
log strWindowName as text
if strWindowName is "書き出しの進行状況" then
tell (item numCntWindow of listEveryWindow)
set bounds to {0, 25, 520, 280}
activate
end tell
set numChkProgressWindow to 1 as number
end if
###"書き出しの進行状況"アリ
set numCntWindow to numCntWindow - 1 as number
end repeat
end if
###結果"書き出しの進行状況"が無い場合はあらためて
if numChkProgressWindow = 0 then
activate
tell application "System Events"
tell process "QuickTime Player"
keystroke "p" using {option down, command down}
end tell
end tell
set numChkProgressWindow to 1 as number
end if
end tell









display notification "処理終了" with title "処理が終了" subtitle "処理が終了しました" sound name "Sonumi"
log ">>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<"
return ">>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<"




#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

end doLogView
#########################

|

[QuickTime]"書き出しの進行状況"を開く

"書き出しの進行状況"

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSNotFound : a reference to 9.22337203685477E+18 + 5807

###おまじない
tell application "System Events"
launch
activate
end tell



tell application "QuickTime Player"
###書き出しWINDOWの有無
set numChkProgressWindow to 0 as number
###QuickTime Playerを前面に
activate
####開いているWINDOWをリストに
set listEveryWindow to every window
log listEveryWindow as list
###ウィンドウの数を数えて
set numCntWindow to count listEveryWindow
log numCntWindow as number
###本来ならこれでようたりるはずなんだけど
if numCntWindow = 0 then
activate
tell application "System Events"
tell process "QuickTime Player"
keystroke "p" using {option down, command down}
end tell
end tell
set numChkProgressWindow to 1 as number
end if
###ウィンドウが1以上なら
if numCntWindow1 then
repeat numCntWindow times
###ウィンドウの名前を取得して
set strWindowName to name of item numCntWindow of listEveryWindow
log strWindowName as text
if strWindowName is "書き出しの進行状況" then
tell (item numCntWindow of listEveryWindow)
set bounds to {0, 25, 520, 280}
activate
end tell
set numChkProgressWindow to 1 as number
end if
###"書き出しの進行状況"アリ
set numCntWindow to numCntWindow - 1 as number
end repeat
end if
###結果"書き出しの進行状況"が無い場合はあらためて
if numChkProgressWindow = 0 then
activate
tell application "System Events"
tell process "QuickTime Player"
keystroke "p" using {option down, command down}
end tell
end tell
set numChkProgressWindow to 1 as number
end if
end tell









display notification "処理終了" with title "処理が終了" subtitle "処理が終了しました" sound name "Sonumi"
log ">>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<"
return ">>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<"




#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

end doLogView
#########################

|

[QuickTime]書き出し

export the front document in aliasSavePath using settings preset "1080p"
export the front document in aliasSavePath using settings preset "720p"
export the front document in aliasSavePath using settings preset "480p"
export the front document in (POSIX file strNewFilePath) using settings preset "4K"
export the front document in aliasSavePath using settings preset "Audio Only"


#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSNotFound : a reference to 9.22337203685477E+18 + 5807

###選択ダイアログのデフォルトパス
tell application "Finder"
set aliasDefaultLocation to (path to desktop folder from user domain) as alias
log aliasDefaultLocation as alias
end tell

####ファイルを選択してlistChooseFileに入れる
set listChooseFile to (choose file with prompt "TSファイルを選んでください" default location aliasDefaultLocation of type {"public.mpeg-2-transport-stream", "com.apple.quicktime-movie", "public.mpeg-4"} with invisibles and multiple selections allowed without showing package contents) as list
log listChooseFile as list


###listChooseFileに入ってるエリアス分だけ繰り返す
repeat with objFile in listChooseFile
###ユニックスパス
set strFilePath to POSIX path of objFile as text
log strFilePath as text
####ファイルエイリアス
set aliasFilePath to objFile as alias
log aliasFilePath as alias
####ファイルのコンテナ(ファイルのあるディレクトリ)のエイリアス
tell application "Finder"
set aliasContainDirPath to container of aliasFilePath as alias
log aliasContainDirPath as text
end tell
###ファイルのあるディレクトリのユニックスパス
set strContainDirPath to POSIX path of aliasContainDirPath as text
log strContainDirPath as text

tell application "Finder"
####ファイルINFOを取得
set objInfo to info for objFile
####ファイル名
set strFileName to name of objInfo as text
####拡張子名
set strExtension to name extension of objInfo as text
end tell
#####ファイル名から拡張子を取り除く
set AppleScript's text item delimiters to "."
set listFileName to every text item of strFileName
set AppleScript's text item delimiters to ""
set numCntDot to (count of listFileName) as number
set strShortFileName to (item 1 of listFileName) as text
log strShortFileName


log "###Input"
log "Alias: " & aliasFilePath
log "POSIX: " & strFilePath
log "FileName: " & strFileName
log "Extension: " & strExtension



tell application "QuickTime Player"
####ファイルをオープンしてobjOpenDocに格納
set objOpenDoc to open file aliasFilePath

tell window 1
set bounds to {0, 75, 520, 280}
properties
end tell
####縦横サイズを取得
tell objOpenDoc
###プロパティをリストにしてから
set listNaturalDimensions to natural dimensions as list
###値を取得する
set strDimensionsW to (item 1 of listNaturalDimensions) as text
set strDimensionsH to (item 2 of listNaturalDimensions) as text
end tell
#####書き出しファイル名
set strNewFileName to (strShortFileName & "_" & strDimensionsW & "x" & strDimensionsH & ".mov") as text
#####書き出しパス
set strNewFilePath to (strContainDirPath & strNewFileName) as text
log "###OutPut"
log "AliasOutPutDir: " & aliasContainDirPath
log "NewFileName: " & strNewFileName
log "NewFilePath: " & strNewFilePath
#####書き出し
##export the front document in aliasSavePath using settings preset "1080p"
##export the front document in aliasSavePath using settings preset "720p"
##export the front document in aliasSavePath using settings preset "480p"
export the front document in (POSIX file strNewFilePath) using settings preset "4K"

##export the front document in aliasSavePath using settings preset "Audio Only"

end tell

end repeat














#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

end doLogView
#########################

|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom