If anyone can help me, I'm having a hard time
I am using timestomper
to change the date of my files, I would like to randomize the date for each file to get random sorting.
This is what I've done so far, the script is definitely very bad, but I've tried...
@echo off & setlocal EnableDelayedExpansion
Set /a _day=(!RANDOM!*25/32768)+1
Set /a _month=(!RANDOM!*12/32768)+1
Set /a _hours=(!RANDOM!*22/32768)+1
Set /a _minutes=(!RANDOM!*60/32768)+1
for /r %%v in (*.jpg) do (
timestomper -z %_month%-%_day%-2022 %_hours%:%_minutes%:01 -p "%%v"
)
the output of my script:
a.jpg 04/12/2010 10:20
b.jpg 04/12/2010 10:20
c.jpg 04/12/2010 10:20
d.jpg 04/12/2010 10:20
What I want is a randomly generated date for each file:
a.jpg 04/12/2010 10:20
b.jpg 10/02/2001 22:02
c.jpg 01/02/2004 15:27
d.jpg 12/20/2008 08:13
What timstomper needs is a date and a path to the file:
timestomper -z 10-20-1994 14:2:01 -p C:\full\path
I hope to be clear in my request
Ok. This is your original code:
@echo off & setlocal EnableDelayedExpansion
Set /a _day=(!RANDOM!*25/32768)+1
Set /a _month=(!RANDOM!*12/32768)+1
Set /a _hours=(!RANDOM!*22/32768)+1
Set /a _minutes=(!RANDOM!*60/32768)+1
for /r %%v in (*.jpg) do (
timestomper -z %_month%-%_day%-2022 %_hours%:%_minutes%:01 -p "%%v"
)
In my advice I said: "You must move the for /r %%v in (*.jpg) do (
command before the first Set /a _day=
command and change the percents in timestomper
invocation by exclamation marks, excepting in the "%%v" part, of course!"
Let's follow these instructions step by step:
"You must move the for /r %%v in (*.jpg) do (
command before the first Set /a _day=
command"
That is:
@echo off & setlocal EnableDelayedExpansion
to here <----+
Set /a _day=(!RANDOM!*25/32768)+1 |
Set /a _month=(!RANDOM!*12/32768)+1 |
Set /a _hours=(!RANDOM!*22/32768)+1 |
Set /a _minutes=(!RANDOM!*60/32768)+1 |
for /r %%v in (*.jpg) do ( from here >--+
timestomper -z %_month%-%_day%-2022 %_hours%:%_minutes%:01 -p "%%v"
)
... giving:
@echo off & setlocal EnableDelayedExpansion
for /r %%v in (*.jpg) do (
Set /a _day=(!RANDOM!*25/32768)+1
Set /a _month=(!RANDOM!*12/32768)+1
Set /a _hours=(!RANDOM!*22/32768)+1
Set /a _minutes=(!RANDOM!*60/32768)+1
timestomper -z %_month%-%_day%-2022 %_hours%:%_minutes%:01 -p "%%v"
)
Then "change the percents in timestomper
invocation by exclamation marks, excepting in the "%%v" part"
@echo off & setlocal EnableDelayedExpansion
for /r %%v in (*.jpg) do (
Set /a _day=(!RANDOM!*25/32768)+1
Set /a _month=(!RANDOM!*12/32768)+1
Set /a _hours=(!RANDOM!*22/32768)+1
Set /a _minutes=(!RANDOM!*60/32768)+1
timestomper -z !_month!-!_day!-2022 !_hours!:!_minutes!:01 -p "%%v"
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.