L
L
lazix2017-11-20 21:03:26
Android
lazix, 2017-11-20 21:03:26

How to bulk change the modification date of files (based on the name)?

Mighty minds, please advise, how can a hundred files like IMG_20170601-125533.jpg change the DATE OF CHANGE or CREATION of a file according to the model name?
Let me explain - I merged photos from the android phone, ran them through iCatalyst to slightly reduce the size, and when I uploaded it back, all the galleries that sort by change time (or whatever it is by default in android) do not show the chronology correctly.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
lazix, 2017-11-21
@lazix

The question about metadata led me to the solution: jhead .
Namely jhead -ft *.jpg

C
CodARM, 2017-11-20
@CodARM

My advice to you, hammer in Yandex: powershell change date file creation
Perhaps the renamer program will help you too, but this is not accurate.

R
res2001, 2017-11-20
@res2001

By standard means, the file date/time can only be changed with a JS/VBS/PoSh script.
You can use, for example, this utility or touch ported from Linux (available in msys2/mingw).
To extract the date/time from the name, use this script:

@echo off
setlocal enabledelayedexpansion
set "filemask=.\*.jpg"

for /f "tokens=* delims=" %%a in ('dir /b "%filemask%" ') do (
  set "file=%%~na"
  set "YEAR=!file:~4,4!"
  set "MONTH=!file:~8,2!"
  set "DAY=!file:~10,2!"
  set "HH=!file:~13,2!"
  set "MM=!file:~15,2!"
  set "SS=!file:~17,2!"

  echo.!YEAR! !MONTH! !DAY! !HH! !MM! !SS!
)

Instead of the echo command, you need to insert the launch of the touch utility with the appropriate parameters, form the date from variables that are initialized from the file name.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question