Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, I need help writing a bat file that will rename a picture
that is dragged onto/into it and rename it as the date (i.e. if
the date is April 2, 2008, the picture will be called
040208.jpg). I have been trying to look up how to write something like this, but I don't know about how to do so. Thank you in advance!

i presume that the date you describe is the system date, and not the date time stamp of the file itself. if you can download and install gawk from here:
save the code below as script.awk
BEGIN{
date=systime()
newfilename=strftime("%m%d%y",date)".jpg"
cmd = "move "file" "newfilename
system(cmd)
}on the command line
c:\test> gawk -f change.awk -v file="file_to change.jpg"
or if you are actually getting the date from the file itself
NR>5{
date=$1
file=$NF
n=split(date,d,"/")
newfilename=d[1]d[2]substr(d[3],1,2)".jpg"
cmd = "move "file" "newfilename
print cmd
#system(cmd) #uncomment to use
exit
}usage:
c:\test> dir file_to_change.jpg | gawk -f script.awk

To use a BAT you need to know the date layout.
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |