0

I have multiple .mydsl files in my dir. I want to assign each file with a unique ID using Python. When I run the python code, any new files and existing files in the specific directory should b assigned with an ID. Could anyone be able to help me with this.

for root, dirs, files in os.walk( './'): 
    for file in files: 
        if file.endswith(".mydsl"): 
            print(os.path.join(file))
Matthias
  • 4,481
  • 12
  • 45
  • 84
Dharshan
  • 37
  • 7
  • 1
    Could you post the code so we may help you with it? – jalazbe Aug 21 '18 at 05:46
  • @jalazbe `for root, dirs, files in os.walk( './'): for file in files: if file.endswith(".mydsl"): print(os.path.join(file))` Basically I am getting the files with that extension and printing it. I want to basically add the UUIDs to each files found – Dharshan Aug 21 '18 at 05:54
  • When you say that "any new files and existing files ... should be assigned with an ID" do you mean that everytime you run the program the ID are assign or that you want to append and ID to the fille name and if it doesn't have it then you generate a new ID for the file? – jalazbe Aug 21 '18 at 06:03
  • @jalazbe You're right. If a file doesn't have an UUID in that dir, it should be assigned an Unique ID. If a file already has one, then you don't need to append to a new ID – Dharshan Aug 21 '18 at 06:28

0 Answers0