Reputation: 18001
How can I easily add 'last modified date' comment to my source files in Visual Studio 2008, so that I don't have to manually update the comment every time I edit the file?
Upvotes: 1
Views: 2657
Reputation: 19
import os
import csv
import time
from os.path import join,splitext
path = r"location of file"
fileinfo=[]
for path,dirs,files in os.walk(path):
for file in files:
datetime = os.path.getmtime(path)
moddatetime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(datetime))
size = os.stat(path).st_size
extension = os.path.splitext(file)[-1]
newrow = [path, file, moddatetime, size]
fileinfo.append(newrow)
def task_csv(filelist=[]):
csv_writer = csv.writer(open('14012021_csv' , 'w', newline=''), delimiter =',')
csv_writer.writerow(['file name:','folderpath:','extensions:','dateandtime'])
for row in filelist:
csv_writer.writerow(row)
task_csv(fileinfo)
Upvotes: 0
Reputation: 137178
If you are using source control then the last modified date can be obtained from the date of the last check in.
If you're working on your own projects then you still should use source control and as you're not affecting anyone else you can check in incomplete code.
If you're working on a project with others you can still do this if you create individual branches and have a suitable merge schedule and procedure in place.
Upvotes: 1
Reputation: 42373
Use a revision control system that supports the RCS $Date$ keyword, such as RCS, CVS, or SVN.
Instructions for doing that in Subversion are here.
Upvotes: 3