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?

Recommended Answers

You're welcome.

Jump to Post

All 2 Replies

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( + extn
        if not os.path.exists(newname):

Save it in a file like and run it by

appenddate file [file...]

where file is a file name or pattern (Windows wildcards * and ?) as in

appenddate *.jpg *.txt

That weird replace in the glob line is to account for [ and ] being valid Windows characters in file names but something else in a glob call.

You're welcome.

commented: excellent +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.