- Script Code -
dofile(reaper.AZ_GetLuaInitPath())
require("reaper_AZSTOKE_BRONZE")
require("reaper_AZSTOKE_SILVER")
require("reaper_AZSTOKE_GOLD")
defaultExcelPath = "D:\\reapdock\\voice\\Recording.xlsx"
function InsertTrackInfo(excelPath)
excel = reaper.AZ_Excel_OpenFile(excelPath)
worksheet = reaper.AZ_Excel_OpenWorksheet(excel, "収録内容")
-- 開始行特定
newRow = 4
searchResult = reaper.AZ_Excel_SearchRowsInWorksheet(worksheet, ".+", "B", newRow..":1000,B", true)
for k, v in pairs(searchResult["Cells"]) do newRow = newRow + 1 end
trackList = reaper.AZ_GetTrackItemList(0)
for i, track in pairs(trackList) do
if reaper.AZ_GetTrackItemDepth(track) == 0 then
trackName = reaper.AZ_GetTrackItemName(track)
searchResult = reaper.AZ_Excel_SearchRowsInWorksheet(worksheet, trackName, "B")
resultRow = ""
for k, v in pairs(searchResult["Cells"]) do
resultRow = k
end
if resultRow == "" then
reaper.AZ_Excel_SetCellValue_ByNumber(worksheet, newRow, 2, trackName)
newRow = newRow + 1
end
end
end
reaper.AZ_Excel_SaveDocument(excel)
reaper.AZ_Excel_CloseFile(excel)
end
function InsertFileInfo(excelPath)
excel = reaper.AZ_Excel_OpenFile(excelPath)
worksheet = reaper.AZ_Excel_OpenWorksheet(excel, "波形名")
-- 開始行特定
newRow = 4
existRows = {}
searchResult = reaper.AZ_Excel_SearchRowsInWorksheet(worksheet, ".+", "D", newRow..":5000,D", true)
for i, line in pairs(searchResult["Cells"]) do
newRow = newRow + 1
table.insert(existRows, line["D"])
end
mediaItemList = reaper.AZ_GetMediaItemList(0)
for i, media in pairs(mediaItemList) do
fileName = reaper.AZ_GetMediaItemName(media)
filenameComponent = reaper.AZ_GetStringSplitList(fileName, "_")
if filenameComponent[#filenameComponent] ~= "ng" then
exist = false
for j, val in pairs(existRows) do
if val == fileName then
exist = true
end
end
if exist == false then
mikeTrack = reaper.GetMediaItemTrack(media)
mikeName = reaper.AZ_GetTrackItemName(mikeTrack)
soundTrack = reaper.GetParentTrack(mikeTrack)
soundName = reaper.AZ_GetTrackItemName(soundTrack)
reaper.AZ_Excel_SetCellValue_ByNumber(worksheet, newRow, 2, soundName)
reaper.AZ_Excel_SetCellValue_ByNumber(worksheet, newRow, 3, mikeName)
reaper.AZ_Excel_SetCellValue_ByNumber(worksheet, newRow, 4, fileName)
newRow = newRow + 1
end
end
end
reaper.AZ_Excel_SaveDocument(excel)
reaper.AZ_Excel_CloseFile(excel)
end
function main()
retval, inputList = reaper.AZ_GetUserInputList("", 1, "Excelパス", defaultExcelPath)
if retval == false then return end
retval, pushedButton = reaper.AZ_ShowMessageBox_Warn("出力先のExcelファイルを閉じていますか?", "", reaper.AZ_WindowType_OK_Cancel())
if retval == false then return end
excelPath = inputList[1]
-- 収録内容
InsertTrackInfo(excelPath)
-- ファイル名
InsertFileInfo(excelPath)
reaper.AZ_ShowMessageBox_Info("Excelへの出力が完了しました。", "", reaper.AZ_WindowType_OK())
end
main()
- Warm Up -
Prepare an Excel file
Prepare the project used for recording
- Script Detail -
dofile(reaper.AZ_GetLuaInitPath())
require("reaper_AZSTOKE_BRONZE")
require("reaper_AZSTOKE_SILVER")
require("reaper_AZSTOKE_GOLD")
・Import RIGDOCKS
defaultExcelPath = "D:\\reapdock\\voice\\Recording.xlsx"
・Excel file path (default)
function InsertTrackInfo(excelPath)
・Function to output track info to the recording-content sheet
excel = reaper.AZ_Excel_OpenFile(excelPath)
worksheet = reaper.AZ_Excel_OpenWorksheet(excel, "収録内容")
・Open the Excel file and open the recording-content sheet
-- 開始行特定
newRow = 4
・Specify the row where track info output starts
searchResult = reaper.AZ_Excel_SearchRowsInWorksheet(worksheet, ".+", "B", newRow..":1000,B", true)
for k, v in pairs(searchResult["Cells"]) do newRow = newRow + 1 end
・ If track info is already output, update the start row to output from the next row
trackList = reaper.AZ_GetTrackItemList(0)
・Get all tracks in the project
for i, track in pairs(trackList) do
・Loop over all tracks
if reaper.AZ_GetTrackItemDepth(track) == 0 then
・Process when the track depth is 0 (for sound tracks)
trackName = reaper.AZ_GetTrackItemName(track)
・Get the track name
searchResult = reaper.AZ_Excel_SearchRowsInWorksheet(worksheet, trackName, "B")
・Search whether the track name is already output to the recording-content sheet
resultRow = ""
for k, v in pairs(searchResult["Cells"]) do
resultRow = k
end
・Get the row number from the search result
if resultRow == "" then
reaper.AZ_Excel_SetCellValue_ByNumber(worksheet, newRow, 2, trackName)
newRow = newRow + 1
・If the track name is not output to the recording-content sheet, output it on the next row
end
end
end
reaper.AZ_Excel_SaveDocument(excel)
reaper.AZ_Excel_CloseFile(excel)
・Save and close the Excel file
end
function InsertFileInfo(excelPath)
・Function to output file names to the waveform-name sheet
excel = reaper.AZ_Excel_OpenFile(excelPath)
worksheet = reaper.AZ_Excel_OpenWorksheet(excel, "波形名")
・Open the Excel file and open the waveform-name sheet
-- 開始行特定
newRow = 4
・Specify the row where file name output starts
existRows = {}
searchResult = reaper.AZ_Excel_SearchRowsInWorksheet(worksheet, ".+", "D", newRow..":5000,D", true)
for i, line in pairs(searchResult["Cells"]) do
newRow = newRow + 1
table.insert(existRows, line["D"])
end
・If the file name is already output, update the start row to output from the next row, and save the already-output file names to a list
mediaItemList = reaper.AZ_GetMediaItemList(0)
・Get all media items in the project
for i, media in pairs(mediaItemList) do
・Loop over all media items
fileName = reaper.AZ_GetMediaItemName(media)
・Get the media item name
filenameComponent = reaper.AZ_GetStringSplitList(fileName, "_")
・Split the media item name by "_" into a list
if filenameComponent[#filenameComponent] ~= "ng" then
・Process only if the last element of the file name is not "ng"
exist = false
for j, val in pairs(existRows) do
if val == fileName then
exist = true
end
end
・Search the list for whether the file name is already output
if exist == false then
・Process only if the file name has not already been output
mikeTrack = reaper.GetMediaItemTrack(media)
mikeName = reaper.AZ_GetTrackItemName(mikeTrack)
・Get the media item's track and get the track name (mic name)
soundTrack = reaper.GetParentTrack(mikeTrack)
soundName = reaper.AZ_GetTrackItemName(soundTrack)
・Get the parent track of the mic track and get the track name (sound name)
reaper.AZ_Excel_SetCellValue_ByNumber(worksheet, newRow, 2, soundName)
reaper.AZ_Excel_SetCellValue_ByNumber(worksheet, newRow, 3, mikeName)
reaper.AZ_Excel_SetCellValue_ByNumber(worksheet, newRow, 4, fileName)
・Output the sound name, mic name, and file name on the next row
newRow = newRow + 1
・Update the row number to output on the next row
end
end
end
reaper.AZ_Excel_SaveDocument(excel)
reaper.AZ_Excel_CloseFile(excel)
・Save and close the Excel file
end
function main()
retval, inputList = reaper.AZ_GetUserInputList("", 1, "Excelパス", defaultExcelPath)
if retval == false then return end
・Have the user enter the Excel file path. defaultExcelPath is pre-filled by default
retval, pushedButton = reaper.AZ_ShowMessageBox_Warn("出力先のExcelファイルを閉じていますか?", "", reaper.AZ_WindowType_OK_Cancel())
if retval == false then return end
・Ask the user to confirm the Excel file is closed. If OK is pressed, continue; if Cancel is pressed, abort
excelPath = inputList[1]
・Save the Excel file path entered by the user to a variable
-- 収録内容
InsertTrackInfo(excelPath)
・ Call the function to output track info to the recording-content sheet
-- ファイル名
InsertFileInfo(excelPath)
・ Call the function to output file names to the waveform-name sheet
reaper.AZ_ShowMessageBox_Info("Excelへの出力が完了しました。", "", reaper.AZ_WindowType_OK())
・Show the output-complete message to the user
end
main()
・Call the main function
- API LINK -
- API LINK -
Excel
AZSTOKE_Recording_OutputMediasToExcel
Export the exported media info to Excel

















