Admiral208 Posted November 16, 2010 Posted November 16, 2010 How can I do this??? I need to copy an image and rename it to YYYYMMDD_HHMM.jpg Cheers James
sonofsanta Posted November 16, 2010 Posted November 16, 2010 Random point while I skive off digging through the T&Cs of a contract: have you looked at IrfanView's batch function? It can do batch renaming, could well be worth a punt.
SpuffMonkey Posted November 16, 2010 Posted November 16, 2010 Heres a similar situation in a batch file I use to save some daily log files - hope its of some help for /F "tokens=1,2" %%d in ('date /T') do set day=%%d & set date=%%e set yyyy=%DATE:~6,4% set mm=%DATE:~3,2% set dd=%DATE:~0,2% set dateserial=%yyyy%%mm%%dd% ren filedel.log %dateserial%_filedel.log 1
Admiral208 Posted November 16, 2010 Author Posted November 16, 2010 I need it as a script that can run as a scheduled task... probably should have mentioned that.
Admiral208 Posted November 16, 2010 Author Posted November 16, 2010 Heres a similar situation in a batch file I use to save some daily log files - hope its of some help for /F "tokens=1,2" %%d in ('date /T') do set day=%%d & set date=%%e set yyyy=%DATE:~6,4% set mm=%DATE:~3,2% set dd=%DATE:~0,2% set dateserial=%yyyy%%mm%%dd% ren filedel.log %dateserial%_filedel.log That's brilliant. Ive been searching for ages. How can I add the time as HHMM after the date?
themightymrp Posted November 16, 2010 Posted November 16, 2010 With a slight modification to the above script you get: @echo off for /F "tokens=1,2" %%d in ('date /T') do set day=%%d & set date=%%e set yyyy=%DATE:~6,4% set mm=%DATE:~3,2% set dd=%DATE:~0,2% set dateserial=%yyyy%%mm%%dd% set hh=%time:~0,2% set mi=%time:~3,2% set timeserial=%hh%%mi% ren filedel.log %dateserial%_%timeserial%.log 1
Admiral208 Posted November 16, 2010 Author Posted November 16, 2010 Brilliant!!!! Just what I needed! Thanks All
somabc Posted November 16, 2010 Posted November 16, 2010 Yes you can use the inbuilt functions 'Time' and 'Date' and pick out the parts you need.
Admiral208 Posted November 17, 2010 Author Posted November 17, 2010 Is there a way to ensure that there is a leading zero in the time part?? When I ran the script this morning, at 8.57am, the file output was 20101117_ 857.jpg, is there a way of displaying 20101117_0857.jpg?? is quite important because the next time the script runs is 10am. this means that the 10am images appears before the 8.57am image because of the filename. Thanks
themightymrp Posted November 17, 2010 Posted November 17, 2010 Change the code slightly to be like this: @echo off for /F "tokens=1,2" %%d in ('date /T') do set day=%%d & set date=%%e set yyyy=%DATE:~6,4% set mm=%DATE:~3,2% set dd=%DATE:~0,2% set dateserial=%yyyy%%mm%%dd% set hours=%time: =0% set hh=%hours:~0,2% set mi=%time:~3,2% set timeserial=%hh%%mi% ren whatever.jpg %dateserial%_%timeserial%.jpg That should do it 1
Admiral208 Posted November 17, 2010 Author Posted November 17, 2010 Thank you. My only problem now is that I wont be able to test until tomorrow morning. Im sure it will be fine though. Thanks again
neodong Posted January 7, 2011 Posted January 7, 2011 i am usually create it with visual basic 6 if the problem using windows operating system
Arthur Posted January 7, 2011 Posted January 7, 2011 When I ran the script this morning, at 8.57am, the file output was 20101117_ 857.jpg, is there a way of displaying 20101117_0857.jpg If your images are from a digital camera or webcam you could use ExifTool to read the time and date directly from the image itself. FOR %%i IN (*.jpg) DO EXIFTOOL -d "%%Y%%m%%d_%%H%%M%%S.jpg" "-FileName
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now