-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWilscript - Batch Process.lua
101 lines (67 loc) · 2.55 KB
/
Wilscript - Batch Process.lua
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
-- REQUIREMENTS:
-- ° Create a CSV with all the file paths in column A
-- ° Create an empty track with the processing you want as its FX chain
-- ° Set the render source in the Render window to "Selected media items via master"
function SplitFilename(strFilename)
-- Returns the Path (excluding filename), Filename (with extension), and Extension as 3 values
return string.match(strFilename, "(.-)([^\\]-([^\\%.]+))$")
end
----------------------------------------------------------------------
function read_lines(filepath)
reaper.Undo_BeginBlock() -- Begin undo group
nboflines = 0
local f = io.input(filepath)
repeat
s = f:read ("*l") -- read one line
if s then -- if not end of file (EOF)
i = 0
linecpt = 0
stringcut = {}
filepath = ""
filepathcopy = ""
for token in string.gmatch(s, "[^,]+") do
stringcut[linecpt] = token
linecpt = linecpt+1
end
filepath = stringcut[0]
-- filepathcopy = filepath:gsub("Test","COPY_test")
-- command = "copy "..filepath.." "..filepathcopy
-- os.execute(command)
track = reaper.GetTrack(0,0)
reaper.SetOnlyTrackSelected(track)
reaper.InsertMedia(filepath,0)
nbitems = reaper.CountMediaItems(0)
currentitemID = nbitems-1
item = reaper.GetMediaItem(0,currentitemID)
reaper.Main_OnCommand(40289,0) -- Unselect all items
reaper.SetMediaItemSelected(item,1)
filepathcopy = filepath:gsub(".wav","_copy.wav")
path,file,extension = SplitFilename(filepath)
pathcopy,filecopy,extensioncopy = SplitFilename(filepathcopy)
-- reaper.ULT_SetMediaItemNote(item, path)
-- reaper.GetSetProjectInfo(0,"RENDER_SETTINGS ",64,true)
reaper.GetSetProjectInfo_String(0, 'RENDER_FILE', path, true)
reaper.GetSetProjectInfo_String(0, 'RENDER_PATTERN', filecopy, true)
reaper.Main_OnCommand(42230,0) -- Render
reaper.DeleteTrackMediaItem( reaper.GetMediaItemTrack(item), item )
os.execute("del /f \""..filepath.."\"")
filepathpeaks = filepath..".reapeaks"
os.execute("del /f \""..filepathpeaks.."\"")
command = "rename \""..filepathcopy.."\" \""..file.."\""
os.execute(command)
end
until not s -- until end of file
f:close()
reaper.Undo_EndBlock("Display script infos in the console", -1) -- End undo group
end
-- START -----------------------------------------------------
retval, filetxt = reaper.GetUserFileNameForRead("", "Import assets", "csv")
if retval then
reaper.PreventUIRefresh(1)
read_lines(filetxt)
-- Update TCP
reaper.TrackList_AdjustWindows(false)
reaper.UpdateTimeline()
reaper.UpdateArrange()
reaper.PreventUIRefresh(-1)
end