11

Is there a short command an addon or an easy and quick way to delete the video I'm currently watching with vlc media player?

Background I have some disc with very much videos and most of them are crap. So I need a tool to quick preview the video and if I decide to delete it I can just do it very fast. Preferably I want do this from vlc.

At moment I use this guide to go to the folder of the video and then I delete it manually. But its a little bit to slow.

3 Answers 3

20

Use the VLC extension vlc-delete :

Usage

When playing a video you can click on View -> VLC Delete. Then the video will be removed and the next one is played.

1
1

Here is a a relatively better script than vlc-delete that I wrote using AutoHotkey (v2+) that not only works when VLC is in true full-screen mode, unlike vlc-delete, but this script also allows using multiple customizable hotkeys to do the following:

  1. Delete the video to recycle bin (default shortcut key: DEL)
  2. Delete the video permanently from disk (default shortcut key: SHIFT+DEL)
  3. Move the video file to an arbitrary location e.g. C:\ (default shortcut key: CTRL+Z)

I added a lot of code comments for your convenience. And, the default shortcut keys can be changed easily to whatever you want, as seen in the code below.

; Delete/Move a playing VLC video (via hotkeys) then jumps to the next video in the playlist.
; ------------------------------------------
; DEL       = Delete video to the recycle bin
; SHIFT+DEL = Permanently delete video of disk
; CTRL+Z    = Move video to arbitrary location
; ------------------------------------------

MOVE_ACTION_DIR := "C:\"
MEDIA_INFO_DIALOG_TITLE := "Current Media Information"
WAIT_FOR_MEDIA_INFO_DIALOG_SECS := 0.25
WAIT_FOR_MEDIA_INFO_DIALOG_RETRIES := 10
CLIPBOARD_WAIT_SECS := 1
WAIT_FOR_NEXT_VID_SECS := 0.10
WAIT_FOR_NEXT_VID_RETRIES := 10
GIVE_BACK_MOUSE_CONTROL_AFTER_SECS := 5

#Requires AutoHotkey >=2.0
#SingleInstance Force
#HotIf WinActive("ahk_class Qt5QWindowIcon")  ; only trigger the use of hotkeys if a VLC window is active

~Shift & Delete:: {  ; SHIFT+DEL = Permanently delete video off disk
    KeyWait "Delete", "Up"
    KeyWait "Shift", "Up"
    DoPermDelete()
    Return
}

~Delete:: {  ; DEL = Delete video to the recycle bin
    KeyWait "Delete", "Up"
    DoRecycleDelete()
    Return
}

~Ctrl & z:: {  ; CTRL+Z = Move video to arbitrary location
    KeyWait "Ctrl", "Up"
    KeyWait "z", "Up"
    DoMove(MOVE_ACTION_DIR)
    Return
}

DoAction(action) {
    BlockInput "MouseMove"  ; block user from using the mouse
    SetTimer AllowMouse, GIVE_BACK_MOUSE_CONTROL_AFTER_SECS * 1000  ; restore the mouse for the user at some point if something goes wrong
    vlcTitle := WinGetTitle("A") ; vlc should be the active window because it's the only way this line got called
    isFullScreen := false

    ; open the media information dialog

    Send "^i" ; CTRL+I is harcoded in vlc to open the media info dialog
    if !WinWait(MEDIA_INFO_DIALOG_TITLE, , WAIT_FOR_MEDIA_INFO_DIALOG_SECS) {
        ; cant find information window - vlc in fullscreen?
        ; attempt to leave fullscreen and retry opening information dialog
        Send "{ESC}" ; leave fullscreen
        Sleep 10
        Send "^i"
        isFullScreen := true ; user was indeed in fullscreen - remember so we can restore it later
        retry := 1
        while !WinWait(MEDIA_INFO_DIALOG_TITLE, , WAIT_FOR_MEDIA_INFO_DIALOG_SECS) {            
            retry++
            if retry == WAIT_FOR_MEDIA_INFO_DIALOG_RETRIES { ; something went wrong.
                Msgbox "Can't find Media Information dialog. Aborting!"
                Return
            }
            Send "^i"
        }
    }

    ; save the full path (as seen in the information dialog) of the video that is playing to the clipboard

    MouseGetPos &orgMouseX, &orgMouseY
    orgClipboardContent := ClipboardAll()
    WinActivate MEDIA_INFO_DIALOG_TITLE
    WinWaitActive MEDIA_INFO_DIALOG_TITLE
    WinGetPos , , &width, &height, MEDIA_INFO_DIALOG_TITLE
    fileLocationX := width/2
    fileLocationY := height-52    
    CoordMode "Mouse", "Window"
    MouseMove fileLocationX, fileLocationY, 1
    Click 3 ; selects the entire path
    Send "^c" ; copies the path to the clipboard
    CoordMode "Mouse", "Screen"
    MouseMove orgMouseX, orgMouseY, 1
    if !ClipWait(CLIPBOARD_WAIT_SECS) {
        WinClose MEDIA_INFO_DIALOG_TITLE
        WinWaitClose MEDIA_INFO_DIALOG_TITLE
        MsgBox "Can't delete/move file!  Problem finding file location nside Media Information dialog."
        Return
    }
    WinClose MEDIA_INFO_DIALOG_TITLE
    WinWaitClose MEDIA_INFO_DIALOG_TITLE

    ; if the user was originally in fullscreen this restore it now

    if isFullScreen {
        ; restore fullscreen if it was orginally set
        WinGetPos , , &width, &height, vlcTitle
        videoX := width/2
        videoY := height/2
        CoordMode "Mouse", "Window"
        MouseMove videoX, videoY, 1
        Click 2
        CoordMode "Mouse", "Screen"
        MouseMove orgMouseX, orgMouseY, 1
    }

    ; move to the next video -- so it can delete/move this video (because vlc locks the running video)

    Send "{PgDn Down}"
    retry := 1
    while WinGetTitle("A") == vlcTitle { ; wait for the next video to start playing
        Sleep WAIT_FOR_NEXT_VID_SECS * 1000 ; give it some more time to move to next video
        retry++
        if retry == WAIT_FOR_NEXT_VID_RETRIES { ; something went wrong.  no more videos? (we cant delete/move if its only 1 video)
            MsgBox "Didn't detect next video change. Only 1 video left?`nCan't delete/move this video."
            Return
        }
    }
    vlcTitle := WinGetTitle("A")

    ; perform action (delete/move the video now)

    BlockInput "MouseMoveOff"  ; allow the user to have control over the mouse now (in case the delete/move takes too long)
    try
        if action == "del_perm"
            FileDelete A_Clipboard
        else if action == "del_recycle" {
            ;WinActivate "ahk_class Shell_TrayWnd"
            ;WinWaitActive "ahk_class Shell_TrayWnd"
            FileRecycle A_Clipboard
        } else
            FileMove A_Clipboard, action
    catch as err
        MsgBox "Problem deleting/moving file:`n`n" A_Clipboard "`n`n(" err.What " - " err.Message ")"
    A_Clipboard := orgClipboardContent
    try
        WinActivate vlcTitle
    catch
        WinActivate "ahk_class Qt5QWindowIcon" ; strange, we can't find the player! ok just activate any vlc window blindly
}

DoPermDelete() {
    DoAction("del_perm")
}

DoRecycleDelete() {
    DoAction("del_recycle")
}

DoMove(path) {
    DoAction(path)
}

AllowMouse() {
    BlockInput "MouseMoveOff"
}
1

For this code to work, you must do 2 things: Open VLC -> Tools -> Preferences (Show settings = ALL) -> Input/Codecs? Then at the very bottom of the right panel set the option "Change title according to current media" to "$F" (without quotes {F= file name and path). Save, exit and restart VLC. autohotkey needs to read the full file path.

Secondly, you must always create a video playlist of more than 1! It will not delete the last remaining (or only) video. To do this, right click on a folder containing your videos (or go into the folder and manually select them), click 'add to VLC media players playlist'. the first video in the playlist starts playing.

Create and run this autohotkey script (below).

Cycle through the videos one-by-one by pressing 'n' for next video or 'p' for previous video. When you wish to delete the video currently playing, press Ctrl + D to move the video to recycle bin and the next video will start playing automatically. Works fine in full screen mode.

#Persistent

; Set the VLC media player window title
SetTitleMatchMode, 2
VLC_WinTitle := "VLC media player"

; Hotkey to delete the current video and play the next one
^d:: ; Ctrl + D to delete the current video and move to the next one
{
    ; Check if VLC is running
    IfWinExist, ahk_exe vlc.exe
    {
        ; Activate the VLC window
        WinActivate, %VLC_WinTitle%
        
        ; Pause the video to release the file lock
        Send, {Space}
        Sleep, 500 ; Wait for the video to pause

        ; Get the file path from VLC window (assuming it shows in the title bar)
        WinGetTitle, WinTitle, %VLC_WinTitle%
        
        ; Extract the file path by removing "file:///" and "- VLC media player"
        if RegExMatch(WinTitle, "file:///([^ ]+)", VideoPath)
        {
            VideoPath := VideoPath1
            ; Convert forward slashes to backslashes for Windows path
            VideoPath := StrReplace(VideoPath, "/", "\\")
            ; Replace "%20" with space
            VideoPath := StrReplace(VideoPath, "%20", " ")

            ; Check if the file exists before trying to delete
            if FileExist(VideoPath)
            {
                ; Play the next video in the playlist
                Send, n ; 'n' is the default hotkey for next in VLC
                Sleep, 1000 ; Wait for VLC to start playing the next video

                ; Delete the video file (move to Recycle Bin)
                FileRecycle, %VideoPath%
            }
            else
            {
                MsgBox, File not found: %VideoPath%
            }
        }
        else
        {
            MsgBox, Unable to determine the currently playing video file.
        }
    }
    else
    {
        MsgBox, VLC Media Player is not running.
    }
}
return

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .