Computing.Net > Forums > Programming > BAT rename jpg to date

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

BAT rename jpg to date

Reply to Message Icon

Name: hartig
Date: April 2, 2008 at 17:26:11 Pacific
OS: XP
CPU/Ram: 2.80GHZ/1GB
Product: Dell/something
Comment:

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!



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: April 2, 2008 at 18:54:12 Pacific
Reply:

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


0

Response Number 2
Name: Mechanix2Go
Date: April 2, 2008 at 19:00:40 Pacific
Reply:

To use a BAT you need to know the date layout.


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: BAT rename jpg to date

PDF how can I add a jpg to page www.computing.net/answers/programming/pdf-how-can-i-add-a-jpg-to-page/4234.html

jpg to htm batch converter www.computing.net/answers/programming/jpg-to-htm-batch-converter/6329.html

Batch rename according to a list www.computing.net/answers/programming/batch-rename-according-to-a-list/18556.html