Python 2.7 在指定的扩展名中使用“否则”重命名文件扩展名

Python 2.7 在指定的扩展名中使用“否则”重命名文件扩展名,python-2.7,path,subprocess,glob,chdir,Python 2.7,Path,Subprocess,Glob,Chdir,我在一个文件夹中有许多具有特定扩展名的文件,我想更改它们的扩展名(与这些文件的特定可执行程序关联) 我有这个高级代码,当运行时它会显示这个错误 C:\Users\user\Desktop\Dats\python listado.py C:\Users\user\Desktop\Dats\COX\DISK1\2014322\B088 Error: [Error 2] The system cannot find the file specified C:\Users\user\Desktop\Da

我在一个文件夹中有许多具有特定扩展名的文件,我想更改它们的扩展名(与这些文件的特定可执行程序关联)

我有这个高级代码,当运行时它会显示这个错误

C:\Users\user\Desktop\Dats\python listado.py
C:\Users\user\Desktop\Dats\COX\DISK1\2014322\B088
Error: [Error 2] The system cannot find the file specified
C:\Users\user\Desktop\Dats\COX\DISK1\2014323\B088
Error: [Error 2] The system cannot find the file specified
C:\Users\user\Desktop\Dats\COX\DISK1\2014324\B088
Error: [Error 2] The system cannot find the file specified
C:\Users\user\Desktop\Dats\COX\DISK1\2014325\B088
Error: [Error 2] The system cannot find the file specified
C:\Users\user\Desktop\Dats\COX\DISK1\2014326\B088
Error: [Error 2] The system cannot find the file specified

嗯,听起来这些文件不存在。无关:传递
cwd=path
而不是
os.chdir(path)
(注意:它不会使不存在的目录出现)
C:\Users\user\Desktop\Dats\python listado.py
C:\Users\user\Desktop\Dats\COX\DISK1\2014322\B088
Error: [Error 2] The system cannot find the file specified
C:\Users\user\Desktop\Dats\COX\DISK1\2014323\B088
Error: [Error 2] The system cannot find the file specified
C:\Users\user\Desktop\Dats\COX\DISK1\2014324\B088
Error: [Error 2] The system cannot find the file specified
C:\Users\user\Desktop\Dats\COX\DISK1\2014325\B088
Error: [Error 2] The system cannot find the file specified
C:\Users\user\Desktop\Dats\COX\DISK1\2014326\B088
Error: [Error 2] The system cannot find the file specified