M
M
Miffer2014-11-22 14:52:58
batch processing
Miffer, 2014-11-22 14:52:58

How to wholesale rename files so that the name has a specific date?

There are ~1500 images, you need to rename them all so that the name of each file contains the future date, 6 files for each day. For example: 22.11.14_1.jpg, 22.11.14_2.jpg, ....... 22.11.14_6.jpg
Maybe there is a plug-in for the total commander, or a ready-made batch file with such an opportunity?
Better under Win, but there is also a server ubunt.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yaroslav Astafiev, 2014-11-22
@Miffer

Well, write a batch file or use another programming language. The task is written in 5 minutes.
As a basis, take a script that numbers them in order.

@echo off

set i=6
set "today=%date%"

CALL:DateToJDN %today% todayNo
CALL:JDNToDate %todayNo% day

for %%f in (*.jpg) do call :renameit "%%f"
goto done

:renameit
set /A i+=1
if %i% GTR 6 (
   set /A i=1
   set /A todayNo += 1
   CALL:JDNToDate %todayNo% day
)

ren %1 %day%_%i%.jpg


:done


:DateToJDN dd.mm.yyyy jdn=
setlocal
set date=%1
set /A yy=%date:~-4%, mm=1%date:~-7,2% %% 100, dd=1%date:~-10,2% %% 100
set /A a=mm-14, jdn=(1461*(yy+4800+a/12))/4+(367*(mm-2-12*(a/12)))/12-(3*((yy+4900+a/12)/100))/4+dd-32075
endlocal & set %2=%jdn%
exit /B

rem Convert Julian Day Number back to date

:JDNToDate jdn dd.mm.yyyy=
setlocal
set /A l=%1+68569,n=(4*l)/146097,l=l-(146097*n+3)/4,i=(4000*(l+1))/1461001,l=l-(1461*i)/4+31,j=(80*l)/2447,dd=l-(2447*j)/80,l=j/11,mm=j+2-(12*l),yy=100*(n-49)+i+l
if %dd% lss 10 set dd=0%dd%
if %mm% lss 10 set mm=0%mm%
endlocal & set %2=%dd%.%mm%.%yy%
exit /B

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question