Open AziRizvi opened 9 months ago
Glad you like it. For SmartCopyPaste, I will do a code review, in the near future hopefully. Since there are multiple features needed. Once I do that, I'll be sure to include this as well.
I am thinking there should be a way to select which parameters to copy and the option to put any parameter you want to copy, to any keybind.
Just the idea, stuff like the below:
copy_keybind=[ ["ctrl+c", "${path}+${filename}+${timepos}"], ["ctrl+x,", "${dirname}"] ]
Also another idea is selective copy, in which a GUI is presented to select the parameter you want to copy. (Looks like too much work, it is only an idea for now)
selective_copy_parameters=["${path}/n${dirname}/n${timepos}/n${filename}\n${path}+${dirname}"]
I will keep the issue open, so I look at this later when conducting the review.
I wrote a small Lua Script for copying the Parent Directory Name from which the current file is playing out of and I thought I should share this so maybe it helps you when you ultimately want to incorporate this functionality in your script and also if anyone needs to use this for now..
I created the code with the help of ChatGPT and I've tested it on various folder names and its working absolutely fine.. The Keybind to trigger the script is MBTN_MID_DBL which people can change..
local mp = require 'mp'
local utils = require 'mp.utils'
local o = {
copy_parent_directory_keybind = 'MBTN_MID_DBL',
}
function bind_keys(keys, name, func, opts)
if not keys or keys == '' then
mp.add_key_binding(nil, name, func, opts)
return
end
for key in string.gmatch(keys, "[^%s]+") do
mp.add_key_binding(key, name, func, opts)
end
end
function is_local_file(path)
return path ~= nil and string.find(path, '://') == nil
end
function copy_parent_directory()
local path = mp.get_property_native('path')
if is_local_file(path) then
local _, _, parent_directory = string.find(path, "([^\\/]+)[\\/][^\\/]+$")
mp.command(string.format('run powershell -command "Add-Type -AssemblyName PresentationCore; [Windows.Clipboard]::SetText(\'%s\')"', parent_directory))
mp.osd_message('Parent Directory Name Copied To Clipboard')
end
end
bind_keys(o.copy_parent_directory_keybind, 'copy-parent-directory', copy_parent_directory)
In case anyone who's reading this doesn't want to use the Lua Script I posted above for whatever reason, here's an alternative approach that I personally find better to use.
I have the following entry in my input.conf Shift+Ins run "R:\MPV\CopyParentDirectoryName.bat" "${path}"
The Shift+Ins command launches a batch file that I have saved in my computer and it passes the $path argument when starting the batch file, this $path argument passes on the path of the currently playing/open file to the batch file and the batch file then extracts the name of the parent directory from the path.
This is the code of said batch file. Save it as whatever name you want to in whatever directory you want to and then just call it with a keybind and you will be able to get the name of the Parent Directory directly copied into your clipboard. Hope this helps someone.
@echo off
REM Extract the last folder name and redirect it directly to a Temp File
for %%I in ("%~dp1.") do echo %%~nxI > Temp.txt
REM Run PowerShell to trim spaces and copy the content to the clipboard
powershell -command "& {(Get-Content Temp.txt).Trim()} | Set-Clipboard"
Is there some way to configure SmartCopyPaste to copy the folder name from which the current file is playing out of? If it's not possible then can I please request this feature?
Since it's possible to copy the full path
H:\Anime[SubsPlease] One Piece - 1075 (720p) [C7C4531E].mkv
It should be possible to trim everything else out and you'd be just left with final output of Anime
I'm using Script Version: SmartCopyPaste_II 3.1.
Thankyou very much for all of your scripts, I've started using SmartSkip and it's amazing!