September 14th, 2013, 08:43 PM
Broken python script
was wondering if anyone could see whats wrong with this script. All its supposed to do is move images into respectable folders or create them if not exist, but for some reason it tries to organize a folder directory too.
# sort multiple image sequences
# creates a folder if it doesn't exist for each image and moves the image to that folder
from collections import OrderedDict
for dirname, dirnames, filenames in os.walk('.'):
for filename in filenames:
# print('Filename: ' + filename)
p = os.path.join(dirname, (os.path.splitext(os.path.splitext(filename))))
# print('P: ' + p)
if not os.path.exists(p):
os.rename(filename, os.path.join(p, filename))
September 14th, 2013, 11:45 PM
Given that leading white space is part of python syntax, and that the html formatting discards extra white space unless you tell it not to, please follow the instructions at my signature to fix your post. Thanks, Dave.
[/code] are essential for python code and Makefiles!