Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

can a dos script be created to do this??

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

can a dos script be created to do this??

Post by ace2 »

OK, the background.
3500 jpg's created between 6am -9pm with Frame number as name.
I want to be able to copy jpg's between 7am -9am based on windows time stamp and repeat this 10am-12pm, 1pm-3pm & 4pm-6pm.

Is this at all possible?

I know there is some script kings out there...... :D
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

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

Post by mcrossley »

This should get you started...

Code: Select all

@echo off
setlocal enabledelayedexpansion
rem get the filename and creation time
for /f "tokens=2,4 skip=5" %%a in ('dir "*" /a-D /tC') do (
	echo checking file %%b
	rem now split the time, and get the hour
	for /f "tokens=1 delims=:" %%h in ("%%a") do (
		rem compare the hour
		if %%h EQU 07 echo 'copy %%b somewhere79\%%b'
		if %%h EQU 08 echo 'copy %%b somewhere79\%%b'
		if %%h EQU 09 echo 'copy %%b somewhere79\%%b'
		if %%h EQU 10 echo 'copy %%b somewhere1012\%%b'
		if %%h EQU 11 echo 'copy %%b somewhere1012\%%b'
		if %%h EQU 12 echo 'copy %%b somewhere1012\%%b'
	)
)
You have to remove the echo on the copy obviously, and you could change the dir "*" to dir "*.jpg" or something. Written on Windows 7 with UK locale.

Edit: I had used forward slashes in the echos - changed to Windows back slashes.
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

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

Post by ace2 »

I can't seem to get that script working right.
It attempts to copy the file size instead of name.

Code: Select all

@echo off
setlocal enabledelayedexpansion
rem get the filename and creation time
for /f "tokens=2,4 skip=5" %%a in ('dir "e:\snap\*.jpg" /a-D /tC') do (
   echo checking file %%b
   rem now split the time, and get the hour
   for /f "tokens=1 delims=:" %%h in ("%%a") do (
      rem compare the hour
      if %%h EQU 07 copy %%b "E:\output\%%b"
      if %%h EQU 08 copy %%b "E:\output1\%%b"
      if %%h EQU 09 copy %%b "E:\output2\%%b"
      if %%h EQU 10 copy %%b "E:\output3\%%b"
      if %%h EQU 11 copy %%b 'E:\output4\%%b"
      if %%h EQU 12 copy %%b "E:\output5\%%b"
   )
)
which is coming up with unable to find file specifies..

screen shot included
Image

The top section is without echo.
with echo on you can see it's using the file size as output name.

Any idea with this???
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
gluepack
Posts: 460
Joined: Tue 22 Jan 2013 9:20 pm
Weather Station: PCE-FWS 20
Operating System: Win 7 Pro
Location: Zlatina, Bulgaria

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

Post by gluepack »

It's only a guess but is there a null field between time and size (would be <dir> for a folder) so should you be picking up 2 and 5 as opposed to 2 and 4. Also, based on your op, I think your time selection is incorrect.
Image

PWS links: WundergroundIVARNAPR3CWOP/APRSE(W)2048PWSWeatherZLATINABGAwekas10631Twitter@Zlatina_weather
Station type: PCE-FWS 20…Webcam link: View south to edge of Provadisko plateau
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

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

Post by mcrossley »

You need to check what the output from your dir /a-D /tC command looks like. Mine is like this...

Code: Select all

 Volume in drive C is PC COE
 Volume Serial Number is 7C55-333E

 Directory of C:\Users\user1

16/01/2014  09:53         5,242,880 NTUSER.DAT
16/01/2014  09:53           262,144 ntuser.dat.LOG1
So it starts with 5 lines of no interest to us, hence "skip=5"
The date is in field 1
The time in field 2
Filesize in field 3
and filename in field 4

So we want tokens 2 & 4 placed in variables %%a & %%b
Last edited by mcrossley on Fri 04 Apr 2014 10:24 am, edited 1 time in total.
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

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

Post by ace2 »

I would have thought mine been a windows 7 machine would be the same.
I did test it on a business machine while at work, so I'll try it on my windows 7 and windows 8 machine once I get home!
I would have thought mine been a windows 7 machine would be the same.
I did test it on a business machine while at wor k, so I'll try it on my windows 7 and windows 8 machine once I get home!

Since I only require time I would change to

Code: Select all

.   For /f "tokens=2 skip=5" %%a in ('dir "e:\snap\*.jpg" /a-D /tC') do (
   echo checking file %%b
   rem now split the time, and get the hour
   for /f "tokens=1 delims=:"%%a")
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

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

Post by mcrossley »

ace2 wrote:Since I only require time I would change to

Code: Select all

.   For /f "tokens=2 skip=5" %%a in ('dir "e:\snap\*.jpg" /a-D /tC') do (
   echo checking file %%b
   rem now split the time, and get the hour
   for /f "tokens=1 delims=:"%%a")
No, you also require the file name, or how else do you know what to copy?
There is a typo in your code, the %%a should be outside the for options quotes.
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

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

Post by ace2 »

OK got it....(poor editing of message on phone lost the "")

Just have to figure out why the original code wouldn't work by checking what field are displayed with a dir
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

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

Post by ace2 »

still at a slight loss with this, i've edited to what was needed 2 and 5(4 was dir name)
with the below script it copies the first 7 to output 3 then nothing else

Code: Select all

@echo off
setlocal enabledelayedexpansion
rem get the filename and creation time
for /f "tokens=2,5 skip=8" %%a in ('dir "E:\snap" /a-D /tC') do (
   echo checking file %%b
   rem now split the time, and get the hour
   
for /f "tokens=1 delims=:" %%h in ("%%a") do (
      rem compare the hour
      if %%h EQU 06 copy E:\snap\%%b E:\output\%%b
      if %%h EQU 07 copy E:\snap\%%b E:\output1\%%b
      if %%h EQU 08 copy E:\snap\%%b E:\output2\%%b
      if %%h EQU 09 copy E:\snap\%%b E:\output3\%%b
      if %%h EQU 10 copy E:\snap\%%b E:\output4\%%b
      if %%h EQU 11 copy E:\snap\ %%b E:\output5\%%b )
   )
)
screen shot Image

source files
Image

Any help from the coding gods would be great...
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

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

Post by mcrossley »

Lets try and get some diagnostics by outputting what it thinks the creation 'hour' is for each file...

Code: Select all

@echo off
setlocal enabledelayedexpansion
rem get the filename and creation time
for /f "tokens=2,5 skip=8" %%a in ('dir "E:\snap" /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: %%b time: %%h
      rem compare the hour
      if %%h EQU 06 copy E:\snap\%%b E:\output\%%b
      if %%h EQU 07 copy E:\snap\%%b E:\output1\%%b
      if %%h EQU 08 copy E:\snap\%%b E:\output2\%%b
      if %%h EQU 09 copy E:\snap\%%b E:\output3\%%b
      if %%h EQU 10 copy E:\snap\%%b E:\output4\%%b
      if %%h EQU 11 copy E:\snap\ %%b E:\output5\%%b )
   )
)
It also seems to be missing the first file, does your dir actually have 8 lines of text before the file list, or 7?
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

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

Post by ace2 »

sorry i had it 7 before but wanted to skip the first file when i changed the folder from *.jpg to folder..

anyway instead of typing everything and a picture is worth a thousand words, where it is :

Image
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

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

Post by ace2 »

add region display setting jpg in case that has a effect as well

Image
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

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

Post by mcrossley »

OK I see why you have to use field 5, you are using a 12 hour time format with am/pm indicator making an additional field 3. This also means he script will not work correctly anyway, the files created the same hours am and pm will be copied to the same destination. It will need reworking to fix this. I'm on a tablet at the more so it will have to be later, 24 hour times are much easier to work with ;)

Your directory listings do not appear to from the same cmd used by the script. The script uses the /a-D parameter to suppress directories, your listings include directories. Also on the explorer view it would be helpful if you added the file creation time column.

I have no idea where the script is getting what should be hours from, the numbers do not correlate with anything I can see on the screen shots.

Please confirm what OS this is running on.
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

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

Post by ace2 »

This one is winDoze 8 and the other one it'll be running on is winDoze 7.
Will put up a screen shot once I'm at home.

And thanks for helping with this
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

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

Post by mcrossley »

Untested as I haven't fiddled with my locale settings to change the time formats to 12hr, but it should cope with the case where there are duplicate hours am and pm...

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=7" %%a in ('dir "E:\snap" /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: %%b 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\%%b E:\output1\%%b
      if %%h==07 copy E:\snap\%%b E:\output1\%%b
      if %%h==08 copy E:\snap\%%b E:\output1\%%b
      if %%h==09 copy E:\snap\%%b E:\output2\%%b
      if %%h==10 copy E:\snap\%%b E:\output2\%%b
      if %%h==11 copy E:\snap\%%b E:\output2\%%b
    ) else (
      rem compare the afternoon hour
      if %%h==12 copy E:\snap\%%b E:\output3\%%b 
      if %%h==01 copy E:\snap\%%b E:\output3\%%b 
      if %%h==02 copy E:\snap\%%b E:\output3\%%b 
      if %%h==03 copy E:\snap\%%b E:\output3\%%b 
      if %%h==04 copy E:\snap\%%b E:\output4\%%b 
      if %%h==05 copy E:\snap\%%b E:\output4\%%b 
      if %%h==06 copy E:\snap\%%b E:\output4\%%b 
    )
  )
)
Last edited by mcrossley on Sat 05 Apr 2014 12:36 pm, edited 1 time in total.
Post Reply