







CodePudding user response:
the import the OSThe import time
Import the random
Path="e:/test/"
File=OS. Listdir # (path) access to the file name in the directory
For I in file:
Old_name=path + I
Re=old_name. Split ('/') [1]. The split ('. ') [1] # get suffix
Times=time. Strftime (' % H % M % S ') # to get minutes when
Time. Sleep (1)
Rand="'. Join (random sample (' 123456789 ', 2)) # for two random number after
New_name=path + STR (times) + rand + ' '+ # re together
OS. Rename (old_name new_name) # modified file name
Print (' file name is changed)
CodePudding user response:
Thanks for the great god help
