Created
March 20, 2026 13:19
-
-
Save maxkagamine/0ead957ae05e91fa33673186c77a8687 to your computer and use it in GitHub Desktop.
mpv: How to bind Delete to recycle the current file on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- This file should be placed in a 'scripts' folder within the mpv config directory. | |
| -- See https://mpv.io/manual/stable/#files-on-windows | |
| mp.register_script_message('delete-file', function() | |
| local path = mp.get_property('path') | |
| local pos = mp.get_property_number('playlist-pos', 0) | |
| local count = mp.get_property_number('playlist-count', 0) | |
| -- This uses the recycle.exe program from wsl-tools (the exe's work outside WSL, too): | |
| -- https://github.com/maxkagamine/wsl-tools/releases | |
| local r = mp.command_native({ | |
| name = 'subprocess', | |
| playback_only = false, | |
| capture_stdout = true, | |
| capture_stderr = true, | |
| args = { 'recycle', '-v', path }, | |
| }) | |
| if r.status == 0 then | |
| mp.commandv('show-text', r.stdout, 2500) | |
| else | |
| mp.commandv('show-text', r.stderr, 5000) | |
| return | |
| end | |
| if pos + 1 < count then | |
| mp.command('playlist-next') | |
| mp.set_property_bool('pause', false) | |
| else | |
| mp.command('playlist-prev') | |
| mp.set_property_bool('pause', false) | |
| end | |
| mp.commandv('playlist-remove', pos) | |
| end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This file should be at the root of the mpv config directory. | |
| # The "#menu" comment is for use with https://github.com/tsl0922/mpv-menu-plugin | |
| Del script-message-to custom delete-file #menu: File > Delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment