VLC使用lua脚本重命名当前项



我使用此脚本作为模板来重命名VLC中的文件:https://github.com/surrim/vlc-delete/脚本按预期工作。

我的代码如下:

function descriptor()
return {
title = "VLC Rename";
version = "0.1";
author = "I";
shortdesc = "Rename current file";
description = [[
<h1>vlc-rename</h1>"
When you're playing a file, use VLC Rename
to rename the current file]];
}
end
function removeItem()
local id = vlc.playlist.current()
vlc.playlist.delete(id)
vlc.playlist.gotoitem(id + 1)
vlc.deactivate()
end
function activate()
local item = vlc.input.item()
local uri = item:uri()
oldFile = vlc.strings.decode_uri(string.gsub(uri, "^file:///", ""))
d = vlc.dialog( "Rename Dialog" )
d:add_label("Filename")
w = d:add_text_input(oldFile, 1, 5,200 ,30)
d:add_button("OK", click_ok)
d:show()
end
function click_ok()
local newFile = w:get_text()
vlc.msg.info("[vlc-rename] renaming: " .. oldFile .. " with " .. newFile)
if newFile ~=  oldFile then
removeItem()
retval, err = os.rename(oldFile,newFile)
vlc.msg.info("[vlc-rename] end rename")
if (retval == nil) then
vlc.msg.err("[vlc-rename]  fail: " .. err)
end
end
d:delete()
vlc.deactivate()
end
function deactivate()
vlc.deactivate()
end
function close()
deactivate()
end
function meta_changed()
end

此代码从os.rename((函数输出一个错误:lua错误:[vlc rename]失败:[my filename]权限被拒绝无论标高如何。

我使用的是windows 10 64位和VLC 3.03。由于这是我的第一个lua脚本,我欢迎任何输入。

我可能错了,但可能你试图重命名的文件已经在其他地方或VLC打开了(你说你想重命名"当前文件"(。

最新更新