Python: различия между версиями
Материал из fidoman.ru
Sergey (обсуждение | вклад) (Новая страница: «=== replace bad character in all filenames in the tree === for a in os.walk('.'): [os.rename(os.path.join(a[0],f), os.path.join(a[0],f.replace(':','='))) if f.f...») |
Sergey (обсуждение | вклад) |
||
| (не показана 1 промежуточная версия этого же участника) | |||
| Строка 2: | Строка 2: | ||
for a in os.walk('.'): [os.rename(os.path.join(a[0],f), os.path.join(a[0],f.replace(':','='))) if f.find(':')!=-1 else 'ok' for f in a[2]] | for a in os.walk('.'): [os.rename(os.path.join(a[0],f), os.path.join(a[0],f.replace(':','='))) if f.find(':')!=-1 else 'ok' for f in a[2]] | ||
| + | |||
| + | use a[1] instead of a[2] for folders instead of files | ||
Текущая версия от 15:04, 13 января 2023
replace bad character in all filenames in the tree
for a in os.walk('.'): [os.rename(os.path.join(a[0],f), os.path.join(a[0],f.replace(':','='))) if f.find(':')!=-1 else 'ok' for f in a[2]]
use a[1] instead of a[2] for folders instead of files