[Feature]: Copy to clipboard mp4 title
SinisterNight opened this issue · comments
Summary
copying file name to keyboard contents and opening directory with file that was recently used
Is your feature request related to a problem?
it will be easier for single use for video creation
Describe the solution you'd like
import os
import pyperclip
import subprocess
def get_newest_directory(directory):
# Get a list of all directories in the specified directory
directories = [d for d in os.listdir(directory) if os.path.isdir(os.path.join(directory, d))]
# Sort directories by modification time (newest first)
directories.sort(key=lambda x: os.path.getmtime(os.path.join(directory, x)), reverse=True)
# Get the name of the newest directory
newest_directory = directories[0]
print("Newest directory:", newest_directory)
return os.path.join(directory, newest_directory)
def get_newest_file_name(directory):
# Get a list of all files in the specified directory
files = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f))]
# Sort files based on modification time (newest first)
files.sort(key=lambda x: os.path.getmtime(os.path.join(directory, x)), reverse=True)
# Retrieve the newest file name
newest_file = files[0] if files else None
print("Newest file:", newest_file)
return newest_file
def main():
# Get the directory of the script
script_dir = os.path.dirname(os.path.abspath(file))
start_directory = os.path.join(script_dir, 'results')
newest_directory = get_newest_directory(start_directory)
print("Newest directory:", newest_directory)
newest_file_name = get_newest_file_name(newest_directory)
print("Newest file name:", newest_file_name)
if newest_file_name:
# Copy the newest file name to the clipboard
pyperclip.copy(newest_file_name)
print("Copied to clipboard:", newest_file_name)
# Open the directory containing the newest file
subprocess.Popen(['explorer', newest_directory])
print("Opened directory:", newest_directory)
else:
print("No files found in the newest directory.")
if name == "main":
main()
Describe alternatives you've considered
manually copying the names is tedious and can add to lag time of video posting if doing semi manually.
Additional Context
output of console
Newest directory: relationship_advice
Newest directory: .\RedditVideoMakerBot\results\relationship_advice
Newest file: My sister told mef26 that he had to convince my now husbandm28 to go on our first couple dates out of pity.mp4
Newest file name: My sister told mef26 that he had to convince my now husbandm28 to go on our first couple dates out of pity.mp4
Copied to clipboard: My sister told mef26 that he had to convince my now husbandm28 to go on our first couple dates out of pity.mp4