📜 ⬆️ ⬇️

timestamp in file name

Tidying up the files on his screw (the free space began to shrink dramatically) was puzzled by the ordering of all sorts of photos and other video files. The names of the files of photos copied from the camera (I have Sony) have a rather uninformative look - DSC00340.JPG. It would be much more convenient, in my opinion, to name files using the date and time of the snapshot. It would be possible to arrange by date / time, and at a glance to determine which era the file belongs to.

Networks brought several program names that could do this procedure, but I was interested in another solution published on pcmag.com. There he signs step by step, with explanations of how to write a bat-file consisting of one (well, 2x, if you count echo off) lines, and performing the task. True, I had to add 1 character, because the standards for displaying time are somewhat different for us and the Americans. I give the final version, who needs the details - a link at the end.

1. Create a rename.bat file containing the lines:
@ECHO OFF
FOR %%V IN (%1) DO FOR /F "tokens=1-5 delims=/:. " %%J IN ("%%~tV") DO IF EXIST %%L%%J%%K_%%M%%N%%~xV (ECHO Cannot rename %%V) ELSE (Rename "%%V" %%L%%J%%K_%%M%%N%%~xV)


2. Run it:
rename.bat *.jpg

in the folder with photos

3. Enjoy the result.
')
Sopno, the result I was pleased, but not very. Not enough seconds. But there are no seconds in the information inside the file (or am I mistaken?). The fact is that I have quite a few photos taken within one minute. Such files this batch file does not rename, but skips, saying that there is absolutely no possibility. Well, because such a file already exists. It would be possible to add the serial number of the photo taken at the moment ... Maybe someone will be able to tell the thread what needs to be replaced with “ECHO Cannot rename %% V”, so that it renames all the files?

Yes, the source is here.

Source: https://habr.com/ru/post/27198/


All Articles