Simple GUI Notepad Using Ruby

GUI Notepad Using Ruby Code require 'tk' class Notepad def saveFile file = File.open("note", "w") ...

Wednesday, February 18, 2015

Renaming Files In A Directory In Sequential Order Using Python Script


Before Running Script
After Running Script




import os

loc = 'E:/My Folder/'
path = os.path.abspath(loc)
i = 1
for file_name in os.listdir(path):
    new_filename = 'File ' + str(i) + file_name[-4:]
    old_filename = loc + file_name
    new_filename = loc + new_filename
    print 'old: ', old_filename
    print 'new:', new_filename
    os.rename(old_filename, new_filename)
    i += 1
print 'Job Done!'