Re: [Tutor] conditional renaming folder and files in the tree

2017-08-14 Thread Mats Wichmann
On 08/14/2017 09:18 AM, banda gunda wrote: > Dear Tutor, > > > I have made some progress! > > But not yet got the results. > > Attached is revised code. > > > Specifically, the problem in below: > > > for root, dirs, files in os.walk(".", topdown=False): > for name in files: >

Re: [Tutor] conditional renaming folder and files in the tree

2017-08-14 Thread Peter Otten
banda gunda wrote: > Dear Tutor, > > > I have made some progress! > > But not yet got the results. > > Attached is revised code. > > > Specifically, the problem in below: > > > for root, dirs, files in os.walk(".", topdown=False): > for name in files: >

Re: [Tutor] conditional renaming folder and files in the tree

2017-08-14 Thread banda gunda
Dear Tutor, I have made some progress! But not yet got the results. Attached is revised code. Specifically, the problem in below: for root, dirs, files in os.walk(".", topdown=False): for name in files: print(os.path.join(root, name)) os.rename(path + name, path +

Re: [Tutor] conditional renaming folder and files in the tree

2017-08-12 Thread Alan Gauld via Tutor
On 11/08/17 16:10, banda gunda wrote: > for root, dirs, files in os.walk(".", topdown=False): > for name in files: > print(os.path.join(root, name)) > os.rename(name.replace("---", "changed")) Here you give the new name but not the original name. The function needs two

[Tutor] conditional renaming folder and files in the tree

2017-08-12 Thread banda gunda
Dear Tutor, I want to change the name of the folders and the files in the tree. All those folders and files starting with name string '---'. Examples: If a folder name is : \---DAT1 I want to change this to: \changedDAT1 If a file name is: \---1.txt I want to change this to: