This is difficult to summarize what I am trying to do, I doubt the Title made it any easier to follow but...
I am using tkinter to build an options dialog box, allowing the user to enter their own file name breakdown structure. Os.Walk would read and setup the folder structure based on the users input.
Config Parser/User Input
[Alpha] aoth = file[:1], file[:3]
The issue is that I can breakdown the structure based on user input (I.E Read 'aoth' in Alpha structure, break down by two folders). However Os.Walk/Python considers this as the actual input. Broke down the code to only show the relevant information:
for root, subFolders, files in os.walk(Entry.get(self.sourceE)):
for file in files:
if not file.startswith('.'):
if file[0].isalpha():
alpfol = '%s' % self.alpha_fol.get()
alset = self.alphaa_radio.get()
if alset == 1:
file_strut = '%s' % file[:1]
elif alset == 2:
file_strut = '%s/%s' % (file[:1], file[:2])
elif alset == 3:
files_strip = [st.strip() for st in (self.radio_aBoxV.get()).split(',')]
files_count = len(files_strip)
###
file_count_check = '%s/'*files_count
file_strut = file_count_check % tuple(files_strip)
###
subFolder = os.path.join(Entry.get(self.destE), alpfol, file_strut)
checkFile = os.path.join(subFolder, file)
........
I know it's not the most elegant code, but alset 1/2 work flawlessly whereas alset 3 considers file[:1]/file[:3] as literal input. How would I make the users input read the actual file name and break down accordingly? I'm sure its something very simple I'm missing.
Thanks for reading this!