Jul-17-2020, 05:40 PM
Hi all,
I've been learning python for a few weeks now and am working on my first, very simple program. To preface this... I've taken inspiration from a couple sources for this in the use of the os and subprocess libraries and some of the logic. I do not copy/paste. I type every line in an effort to learn and understand.
The goal of the program is to simply throw a command at ffmeg via the command line or terminal to generate and save screenshots.
I'm struggling with outputting a list of files in a directory, having a user select from the output, and then taking that selection's file location (currently derived through existing objects) and using it as part of the save location for the screenshots.
In taking inspiration from other scripts, I have the made some mistakes. The return is outside of the function and am probably missing something else.
Any help in identifying where I need to make adjustments would be much appreciated.
I've been learning python for a few weeks now and am working on my first, very simple program. To preface this... I've taken inspiration from a couple sources for this in the use of the os and subprocess libraries and some of the logic. I do not copy/paste. I type every line in an effort to learn and understand.
The goal of the program is to simply throw a command at ffmeg via the command line or terminal to generate and save screenshots.
I'm struggling with outputting a list of files in a directory, having a user select from the output, and then taking that selection's file location (currently derived through existing objects) and using it as part of the save location for the screenshots.
In taking inspiration from other scripts, I have the made some mistakes. The return is outside of the function and am probably missing something else.
Any help in identifying where I need to make adjustments would be much appreciated.
# Importing all necessary libraries import os import subprocess # Create location objects and set working directory source = input("Enter Video Location: ") ssDest = str(source) + "/screenshots" os.chdir(source) files = os.listdir(source) # Identify target video file for f in files: print("#(0): {1}".format(n, f['title'])) choice = "" n = 1 n += 1 if n > 8: break while True: choice = input("Pick a file: ") if choice.isdigit(): choice = int(choice) break else: return 0 # Throw command at ffmeg subprocess.call(['ffmeg', '-i', str(source) + str(n) + '.png', str(ssDest)])P.S. The goal is to make this part of a larger program with more functionality as I learn. I'll create classes and methods once I start working on the second piece of the project. I really need more practice with the basics (loops, functions, standard libraries, etc).