Pretty self-explanatory
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4 KiB

import os, glob
def main():
exts = ('.jpg', '.webm', '.png', '.mp4', '.gif')
print("The Source directory is " + os.getcwd())
newdir = str(input("Please enter a directory:"))
if not os.path.isdir(newdir): # Checks if directory exists
print("Directory does not exist")
else:
directory = os.path.join(os.getcwd(), newdir) # If true, sets directory to new dir, and changes dir
os.chdir(directory)
print("Directory found " + os.getcwd())
# file_list=glob.glob('*.png') #checks to see if files are in directory, asks user if they look familiar
frecognize(directory, exts)
frename(exts, directory)
#frecognize(directory, exts)
def frecognize(directory, exts):
file=[]
#i = 0
#while i < 3:
for file in os.listdir(directory):
if file.endswith(exts):
print(file)
#i += 1
def frename(exts, directory):
filename=[]
source = directory + filename
newname = str(input("Please enter the new filename: "))
index = 0
for filename in os.listdir(directory):
if glob.glob('*.png') == 1:
pngname = newname + "_" + str(index + 1) + ".png"
os.rename(filename, pngname)
elif glob.glob('*jpg') == 1:
os.rename(folder, newname + "_" + str(index + 1) + ".jpg")
main()
# todo add gui
# todo make frecognize do what I want it to (print x amount of files)