forked from filebot/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmi.groovy
27 lines (21 loc) · 1.04 KB
/
mi.groovy
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
// filebot -script fn:mi /path/to/media/ "MediaIndex.csv"
/*
* Print media info of all video files to CSV file
*/
def model = '''Name;Container;Resolution;Video Codec;Video Format;Audio Codec;Audio Format;Audio Language(s);Subtitle Language(s);Duration;File Size;Folder Size;Folder Count;Path'''
def template = '''{fn};{cf};{resolution};{vc};{vf};{ac};{af};{media.AudioLanguageList};{media.TextLanguageList};{media.DurationString3};{file.length()};{folder.listFiles().sum{ it.length() }};{folder.listFiles().sum{ it.isFile() ? 1 : 0 }};{file.getCanonicalPath()}'''
// sanity check
if (args.size() != 2) die('Invalid arguments:' + args)
// open destination file (writing files requires -trust-script)
args[1].withWriter{ output ->
// print header
output.writeLine(model)
// print info for each video file (sorted by filename)
args[0].getFiles{ it.isVideo() }.sort{ a, b -> a.name.compareToIgnoreCase(b.name) }.each{
def mi = getMediaInfo(file:it, format:template)
// print to console
println mi
// append to file
output.writeLine(mi)
}
}