Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by Avinash Raj for multiple file rename based on modification date

Through python,

script.py

import os
import shutil
directory = sys.argv[1]
count = '0'
for item in os.listdir(directory):
    count = str(int(count)+1)
    newname = re.sub(r'.*', count+'.txt', item)
    shutil.move(directory+"/"+item, directory+"/"+newname)

How to run?

python3 script.py /path/to/the/directory

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>