Jul-11-2017, 04:17 PM
(This post was last modified: Jul-11-2017, 05:33 PM by ichabod801.)
I don't think os.walk would work here. It could find all the fileA's and all the fileB's, but how would it know that the oranges fileA matches with the tomato fileB?
The matching pairs would need to be hard coded or put into a data file that can be read. If your folder structure is consistent you could loop over the pairs:
The matching pairs would need to be hard coded or put into a data file that can be read. If your folder structure is consistent you could loop over the pairs:
pairs = [('oranges', 'tomato'), ('banana', 'lettuce'), ('apple', 'carrot')] def file_mod(pathA, pathB): fileA = open(pathA) fileB = open(pathB, 'w') # modify file... for nameA, nameB in pairs: file_mod('/fruit/{}/fileA'.format(nameA), '/veggies/{}/fileB'.format(nameB))
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures