forked from vdcrim/AvsP-macros
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Random Clip Order.py
32 lines (30 loc) · 957 Bytes
/
Random Clip Order.py
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
# Imports all files from a directory and joins them in a random order
# All files must have the same attributes such as size and framerate
import os
import random
import string
# Get the directory containing source files
dirname = avsp.GetDirectory()
if dirname:
avsp.NewTab()
scripttxt = ''
counter = 0
#import each clip
for filename in os.listdir(dirname):
fullname = os.path.join(dirname, filename)
if os.path.isfile(fullname):
counter += 1
scripttxt += 'video' + str(counter) + ' = ' + avsp.GetSourceString(fullname) + '\n'
scripttxt += '\n'
#join clips together
cliplist = []
cliptxt = ''
while counter > 0:
cliplist.append('video' + str(counter))
counter -= 1
random.shuffle(cliplist)
for clip in cliplist:
cliptxt += clip + ' ++ '
cliptxt = cliptxt[:-4] #remove extra ++ from end
scripttxt += cliptxt
avsp.SetText(scripttxt)