Page 2 of 2

Re: can a dos script be created to do this??

Posted: Sat 05 Apr 2014 12:31 pm
by ace2
I shall stay awake to the wee hours after work testing this...

Thank you

Re: can a dos script be created to do this??

Posted: Sat 05 Apr 2014 2:46 pm
by ace2
I was so hoping you nailed it, but sorry it doesn't work right, it doesn't seem to be getting the file name, instead taking the am/pm as name..

I have included a fullscreen shot of dir /a-D /tC + creation/modified with what the output is(zero copied as well)

Image

Your going to have to start charging me for your time!!!

Re: can a dos script be created to do this??

Posted: Sat 05 Apr 2014 3:05 pm
by mcrossley
My mistake, I did say it was untested. I forgot when I added the extra token for am/pm to increment the variable names...(typed on my phone this time!)

Code: Select all

@echo off
setlocal enabledelayedexpansion
rem get the filename and creation time
rem output: dd/mm/yyyy hh:mm AM|PM    9,999,999 FILENAME.EXT
for /f "tokens=2,3,5 skip=5" %%a in ('dir "E:\snap\*.jpg" /a-D /tC') do (
  rem now split the time, and get the hour
  for /f "tokens=1 delims=:" %%h in ("%%a") do (
    echo checking file: %%c time: %%a hour: %%h  am/pm: %%b
    rem is the file creation am or pm
    if /i %%b==AM (
      rem compare the morning hour
      if %%h==06 copy E:\snap\%%c E:\output1\%%c
      if %%h==07 copy E:\snap\%%c E:\output1\%%c
      if %%h==08 copy E:\snap\%%c E:\output1\%%c
      if %%h==09 copy E:\snap\%%c E:\output2\%%c
      if %%h==10 copy E:\snap\%%c E:\output2\%%c
      if %%h==11 copy E:\snap\%%c E:\output2\%%c
    ) else (
      rem compare the afternoon hour
      if %%h==12 copy E:\snap\%%c E:\output3\%%c
      if %%h==01 copy E:\snap\%%c E:\output3\%%c
      if %%h==02 copy E:\snap\%%c E:\output3\%%c
      if %%h==03 copy E:\snap\%%c E:\output3\%%c
      if %%h==04 copy E:\snap\%%c E:\output4\%%c
      if %%h==05 copy E:\snap\%%c E:\output4\%%c
      if %%h==06 copy E:\snap\%%c E:\output4\%%c
    )
  )
)

Re: can a dos script be created to do this??

Posted: Sat 05 Apr 2014 3:38 pm
by ace2
just a long shot, is there anyway of using the date modified instead of the creation date??

It shouldn't matter too much as the creation date won't be altered, but this fails if i say move them to another location...

It doesn't matter if it can't be done..

My plans for this script are to create time lapse videos say of the last hour or 2..

Eg.

9am run script to copy jpg's 6 to 8am and convert to mp4, then at 10am to copy 8am to 9am and so on over writing the mp4

Re: can a dos script be created to do this??

Posted: Sat 05 Apr 2014 3:43 pm
by ace2
and I can't test if its fully functioning until after 6am cause all my jpg's have been copied to another folder so script will see it as creation date..

Re: can a dos script be created to do this??

Posted: Sat 05 Apr 2014 4:11 pm
by mcrossley
Change /tC to /tW to get the last modified time

Re: can a dos script be created to do this??

Posted: Sun 06 Apr 2014 2:08 am
by ace2
:clap: :clap: 110% working :clap: :clap:

you're a genius!!!!!!!

Thanks for your skills with this script. Now to write up the full script.................

Re: can a dos script be created to do this??

Posted: Sun 06 Apr 2014 6:10 am
by ace2
Ok, been playing around with this script and have put something together.

I've added it to my webcam page to upload every hour the last 2 hours on the hour in a time lapse format mp4.
It's up and running between the hours of 5am - 8pm(ACST)

At the moment i have the Mp4 opening in a new browser window.

So your script is a success....... :clap:

Next project, overlay weather information with scripting.......................But that's another story.............

So once again, thank you thank you....

Edit: its now opening in a another page, didn't like the mp4 opening in a separate window on it own.