-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2mp3.lua
More file actions
executable file
·26 lines (17 loc) · 790 Bytes
/
Copy path2mp3.lua
File metadata and controls
executable file
·26 lines (17 loc) · 790 Bytes
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
#!/usr/bin/env luajit
package.path = (arg[0]:match("@?(.*/)") or arg[0]:match("@?(.*\\)")) .. "lib" .. package.config:sub(1, 1) .. "?.lua;" .. package.path
local utility = require "utility"
local argparse = utility.require("argparse")
local parser = argparse():description("Converts everything in the local directory to mp3, placed in \"./2mp3-output\".")
local options = parser:parse()
utility.required_program("ffmpeg")
local for_files = utility.ls()
os.execute("mkdir 2mp3-output")
for_files(function(file_name)
local _, name, extension = utility.split_path_components(file_name)
if extension then
name = name:sub(1, -(#extension + 2))
end
local command = "ffmpeg -i \"" .. file_name .. "\" -acodec mp3 \"2mp3-output/" .. name .. ".mp3\""
os.execute(command)
end)