I am not a programmer but I tried to automate renaming thousands of files using python. but this error appear. I've tried to shorten the path using win32api, using \\?\
notation before the path, even moving the folder to drive C:\ to shorten the path but the error still exist. I want the name of files to add 0 depending how many the files are. ex: if I have 2000 files, I want the name to be x0000,x0001, x0012, until the last x2000
import os, win32api
def main():
i = 0
path = "C:/New folder/"
path = win32api.GetShortPathName(path)
while i < len(os.listdir(path))+1:
filename = os.listdir(path)
s = len(str(i))
p = "x" + ("0" * (4-int(s))) + str(i) + ".jpg"
my_dest = p
my_source = path + str(filename)
my_dest =path + my_dest
os.rename(my_source, my_dest)
print(my_dest)
i+=1
if __name__ == '__main__':
main()