Shoutbox

Make a batch file please? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Make a batch file please? (/showthread.php?tid=92916)

Make a batch file please? by MeEtc on 11-15-2009 at 03:08 AM

Can someone assist with making a batch file that does the following:
take a command line argument as a filename without the path
rename the file to be in the format of mm.dd.yyyy-hh.mm.AA-filename.ext
where the date format is the current date and time ex 11.14.2009-12.00.am-filename.ext

the batch file will be in the same directory as the original file.

thanks? (A)


RE: Make a batch file please? by Jarrod on 11-15-2009 at 06:41 AM

I can do it in python in like 1 minute it you don't mind python rather than a batch file, or you could use a program with batch rename eg alsee or adobe bridge


RE: Make a batch file please? by MeEtc on 11-15-2009 at 06:53 AM

sonicsam is working on it... having some errors though.
and no, it needs to be something that runs in the background.


RE: Make a batch file please? by prashker on 11-15-2009 at 07:23 AM

It's been solved :p

YOU'RE WELCOME


RE: Make a batch file please? by Jarrod on 11-15-2009 at 10:03 AM

I finished about 2 minutes after sam posted, but anyway

python code:
import sys,os,time
year=time.localtime()[0]
month=time.localtime()[1]
date=time.localtime()[2]
hour=time.localtime()[3]
mins=time.localtime()[4]
if hour >=12 and hour<23:
hour=hour-12
med="pm"
else:med="am"
os.rename(sys.argv[1],"%s.%s.%s-%s.%s.%s-"%(month,date,year,hour,mins,med)+sys.argv[1])