Can anyone suggest a script that will rename a file with the
existing filename appended with date stamp? Something that
can be used in a .bat file?
Python or vbScript? This is the Python version
import os import sys import glob import shutil import datetime for arg in sys.argv[1:]: for file in glob.glob(arg.replace("[", "[")): base,extn = os.path.splitext(file) newname = base + ' ' + str(datetime.date.today()) + extn if not os.path.exists(newname): shutil.move(file,newname)
Save it in a file like
appenddate.py and run it by
appenddate file [file...]
file is a file name or pattern (Windows wildcards * and ?) as in
appenddate *.jpg *.txt
replace in the glob line is to account for
] being valid Windows characters in file names but something else in a glob call.