Changed to using variables for input and output folder instead of hardcoding it in. Added more comments
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
#!/usr/bin/python3
|
|
|
|
# Import the required libraries
|
|
from os import listdir, system
|
|
from os.path import isfile, join
|
|
|
|
# Set the in and out folders
|
|
InFolder="ImagesIn"
|
|
OutFolder="ImagesOut"
|
|
|
|
# Make a list with all the files in the appropriate folder
|
|
onlyfiles = [f for f in listdir(InFolder) if isfile(join(InFolder, f))]
|
|
|
|
# Check file type and do the appropriate action
|
|
for f in onlyfiles:
|
|
if f[-4:] == ".mp4":
|
|
print(f + " is an mp4 file, converting to GIF.")
|
|
# Convert to GIF
|
|
system("ffmpeg.exe -i \"" + InFolder + "\\" + f + "\" -nostats -loglevel 0 \"" + OutFolder + "\\" + f[:-4] + ".gif\"")
|
|
elif f[-5:] == ".webm":
|
|
print(f + " is a WebM file, converting to GIF.")
|
|
# Convert to GIF
|
|
system("ffmpeg.exe -i \"" + InFolder + "\\" + f + "\" -nostats -loglevel 0 \"" + OutFolder + "\\" + f[:-5] + ".gif\"")
|
|
else:
|
|
print(f + " is not an mp4 or WebM file, copying image.")
|
|
system("copy /V \"" + InFolder + "\\" + f + "\" \"" + OutFolder + "\\" + f + "\"")
|
|
|
|
# Print status message
|
|
print("That was all the files.")
|
|
|
|
# Thank the user
|
|
print("Thank you for using my tool!")
|