我想通过 tkinter 列表框重命名目录中的所有文件。
在这一点上卡住了:
files_list = os.listdir(root.foldername)
print(files_list)
给我
['1.mp4', '10.mp4', '2.mp4', '3.mp4', '4.mp4', '5.mp4', '6.mp4', '7.mp4', '8.mp4', '9.mp4']
values = [listbox.get(idx) for idx in listbox.curselection()]<br>
和
inlist = (', '.join(values))<br>
print(inlist)
给我
Lost - 1x01 - Pilot(1), Lost - 1x02 - Pilot(2), Lost - 1x03 - Tabula Rasa, Lost - 1x04 - Walkabout, Lost - 1x05 - White Rabbit, Lost - 1x06 - House Of The Rising Sun, Lost - 1x07 - The Moth, Lost - 1x08 - Confidence Man, Lost - 1x09 - Solitary, Lost - 1x10 - Raised By Another
现在我正在寻找使用 os.rename 的解决方案,以便将文件重命名为 1.mp4 到 10.mp4。此外,无论出于何种原因,Python 都没有内置的自然排序方式,因此它对 1.mp4 和 10.mp4 进行排序。
非常感谢您提前。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句