From 325b3d5f010f9b501b10657eb85513daba34b7f7 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Tue, 4 Aug 2020 00:41:15 +0800 Subject: [PATCH] [bugfix] not working on windows if path contains unicode --- config/mpv/scripts/organize.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/config/mpv/scripts/organize.lua b/config/mpv/scripts/organize.lua index f6ececd..d14d1b6 100644 --- a/config/mpv/scripts/organize.lua +++ b/config/mpv/scripts/organize.lua @@ -20,7 +20,11 @@ end function delete_file() mp.commandv('playlist-next', 'force') local path = get_path_info() - os.remove(path) + if package.config:sub(1,1) == '\\' then + utils.subprocess({ args={'cmd', '/c', 'del', path}, cancellable=false}) + else + os.remove(path) + end end function move_file(folder) @@ -30,7 +34,11 @@ function move_file(folder) local dest_dir = utils.join_path(work_dir, folder) local dest_path = utils.join_path(dest_dir, name) os.execute('mkdir "' .. dest_dir .. '"') - os.rename(path, dest_path) + if package.config:sub(1,1) == '\\' then + utils.subprocess({ args={'cmd', '/c', 'move', path, dest_path}, cancellable=false}) + else + os.rename(path, dest_path) + end end end