This is the solution I came up with. <br><br> for dirItem in directoryList:<br> directoryListLower.append(dirItem.lower())<br><br> #---Loop for file name comparison.<br> for item in lineList: # For every item in the 'lineList'
<br> if item in directoryList: # If the item is also in 'directoryList'<br> # Print out so I know it is found.<br> print match.ljust(20) + item.ljust(20) \<br> + directoryList[directoryList.index
(item)]<br> else: # If it isn't found, print what didn't match.<br> # Use the lowercase form from each list to find what didn't match.<br> if item.lower() in directoryListLower: <br> # Print out so I can see why it failed.
<br> print fail.ljust(20) + item.ljust(20) + \<br> directoryList[directoryListLower.index(item.lower())]<br> os.rename(pathName + \<br> directoryList[directoryListLower.index
(item.lower())], \<br> pathName + item)<br><br><div><span class="gmail_quote">On 10/18/06, <b class="gmail_sendername">Luke Paireepinart</b> <<a href="mailto:rabidpoobear@gmail.com">rabidpoobear@gmail.com
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Chris Hengge wrote:<br>> If that last post to Luke didn't clear anything up.. lets try this at
<br>> a smaller level...<br>> I'm going to ignore the fact that my program already renames the file<br>> properly..<br>><br>> I have list1 of filenames<br>> I have list2 of filenames<br>><br>> Item from list 1 needs to be found in list2, but I can't change cases,
<br>> because thats what I'm looking for. I suppose, I could .sort each list<br>> after chopping the extra files names out of list2 that aren't in<br>> list1. then all I have to do is list1[count] = list2[count]<br>
><br>> What I'd like to know, is why my program works, if I can't get it to<br>> display the proper filename in the 3rd output column. I guess<br>> os.rename(notcasesensitive, iscasesensitive) ?<br>><br>I doubt
os.rename is case insensitive for the first argument.<br><br>Okay, here is what you're trying to do.<br>Assuming I haven't seen your code before and I'm writing it from scratch.<br><br>I have a list of filenames.<br>list1 = ['
a.exe', 'b.exe', 'c.exe', 'e.exe']<br>I could've read these in from a file, or anything.<br>It doesn't matter where they came from.<br>The important thing is that they have the case that I want.<br><br>Say I also have another list.
<br>list2 = ['a.ExE',' B.exe', 'C.EXE', 'd.EXE','E.eXe']<br>we got this list maybe from a directory listing or something. It<br>doesn't matter.<br><br>What we're trying to do is: apply any case changes that are necessary to
<br>make all of list1's items' counterparts<br>in list2 be the same. I.E., 'a.ExE' in list2 becomes 'a.exe' from list1.<br><br>We'll assume that if there is an item in list2 that doesn't have a<br>counterpart in list1,<br>
that we just don't care. So 'd.EXE' is going to be 'd.EXE' after the<br>program is run,<br>because there is no corresponding item in list1. In other words,<br>if there are extra files in the directory that we don't need to fix the
<br>case for, we'll just ignore them.<br><br><br>So, without thinking about the implementation, what is it we want to do?<br><br>for every item in list1,<br>check it against each item in list2.<br>if the case-insensitive version of the list1 item is equal to the
<br>case-insensitive version of list2,<br>and the case-sensitive versions aren't equal,<br>we know we need to change the case.<br><br>Otherwise, if the case-sensitive versions are equal,<br>we don't need to change case, but we'll tell them so.
<br><br>if the case-insensitive version of list1 item is not equal to the<br>case-insensitive version of the list2 item,<br>we don't care. It's one of the things that we don't need to change.<br><br><br>So what would this look like in python code?
<br><br>for item1 in list1:<br> for item2 in list2:<br> if item1.lower() == item2.lower(): #they're the same file if you<br>ignore case<br> if item1 != item2: #but there's some case error,<br>
os.rename(item1,item2)<br> print "%s is not %s" % (item1, item2)<br> else:<br> print "%s is %s" % (item1,item1)# or (item1, item1), or<br>(item2,item2), since they're equivalent.
<br><br>I think this is what you wanted.<br>The way you were trying to explain it just confused everyone.<br><br>Hope that helps,<br>-Luke<br><br></blockquote></div><br>