Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi Gurus,
I have 1000's of photos named in following format by a Nokia phone camera:ddmmyyyyXXX.jpg
XXX is a sequential number but varies in length. First photo is 001. However, after 999 it becomes XXXX as required. I assume it goes to XXXXX also but have not found out yet.
The good news is that the first part of the existing filename (ddmmyyyy) is always the same length.
e.g. New Years eve photo's might be
3112200900674.jpg
3112200900675.jpg
0101201000676.jpg (after midnight)I want to rename them all in American date format so that I can sort & manipulate them in a chronological order using filename alone. I have programs that are unable to sort by 'date modified' etc.
Desired format is:
yyyymmddXXX.jpg
Can this be done?
How?All the best,
Nigel (Australia)

:: JPGREN.BAT Usage: jpgren Folder_Name @echo off & setlocal EnableDelayedExpansion pushd %* echo.& echo. Renaming .jpg files in "%CD%", please wait... for %%j in (*.jpg) do ( set _name=%%~nj set _date=!_name:~4,4!!_name:~2,2!!_name:~0,2! set _name=!_name:~8! ren %%j !_date!!_name!.tmp ) ren *.tmp *.jpg echo. DONE popd :: End_Of_Batch

OK very awesome! I am impressed.
However, my fault, I did not quite think the spec through enough. After I tested your code (thanks again it was a total blast seeing it do exactly what I asked you for!) I realised that the number of digits after the date (i.e. XXX, XXXX, or XXXXX) sets an order of magnitude that then 'dominates' the filename sorting.
Is it possible to make another bat file, or ideally add it to the current one as a "second" pass I think, that takes all characters after the constant 8-digit date and always puts it into a 6-digit XXXXXX format? I say 6-digits as then you could easily deal with an essentially infinite (i.e. 10e6 - 1) number of photos, although, by the way, I am only dealing with a few 1000, maybe into 10,000's eventually.
To truly work the following is required:
e.g.
yyyymmdd012.jpg >> yyyymmdd000012.jpg
yyyymmdd937.jpg >> yyyymmdd000937.jpg
yyyymmdd2345.jpg >> yyyymmdd002345.jpgCurrently, after I ran your code, then I sorted, ascending, by filename, I see that 20090728 ends up sorted "after" the more recent dates because it has the larger XXXX and hence magnitude.
i.e.
20090825010 (XXX= 010) (2nd oldest)
20090902011 (XXX= 011) (3rd oldest)
20090922012 (XXX =012) (newest date)
200907281000 (XXXX=1000) (oldest date, should be at top)In proposed scheme it would be correctly sorted before the more recent date in true chronological order.
20090728001000 (XXXXXX=001000)
20090825000010 (XXXXXX=000010)
20090902000011 (XXXXXX=000011)
20090922000012 (XXXXXX=000012)I truly appreciate your time so far and am very exited that this will truly work and be useful to not only me but possibly some of the other billion (guessing) Nokia phone camera users.
All the best,
Nigel (Australia)

Check your Private Message area as I sent you a message with my mail address so you can contact me by e-mail.

Contact me, your script is ready, professional coded, with input checking, on-line help and switches to process date,sequence number or both.

![]() |
Rename folders via anothe...
|
Macro to count entries
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |