Complicated setup for viewing pictures

May 3, 2010 at 10:48:02
Specs: Windows 7
Here is what I need to do:

Setup:
1 Canon 50D camera that saves photos as they are shot in a SubDirectory with that days' date (e.g. 5-3-2010) I have a computer that has a 4 monitor display that needs to run the slideshow showing not the last 30 minutes, but the 30 minutes prior to that on the displays.

So what I am thinking is a batch file that will copy over the photos from 30-60 minutes ago based on file creation time into a directory on the display computer. The same chron job that sets that off every 30 minutes, also deleting everything in the folder before the copy. Second part is easy enough, jsut wondering what I can do about the first part. Thoughts?


See More: Complicated setup for viewing pictures

Report •


#1
May 3, 2010 at 14:51:45
da.vbs used in the foll. script is here:

@echo off & setlocal enabledelayedexpansion
set t0=%time%
set t0=%t0:~0,-3%
for %%c in (30 60) do (
:: the script in the followin line does the math
for /f "tokens=*" %%a in ('cscript /b da.vbs %t0% -%%c') do set t%%c=%%a
set test=!t%%c:~1,1!
if "!test!" equ ":" set t%%c=0!t%%c!
set t%%c=!t%%c:~9!!t%%c:~0,5!
)
echo these times are 30 to 60 minutes: !t30! !t60!
echo following files should be the ones that qualify:
for %%a in (*.*) do (
for /f "tokens=1*" %%b in ('echo %%~ta') do (
set x=%%c
set x=!x:~6!!x:~0,5!
if !x! gtr !t30! if !x! lss !t60! echo %%a %%c
)
)
::------ end

the vbs script does the time math. It can be done in batch,
but it's quite a bit bigger.


Report •

#2
May 4, 2010 at 09:17:10
Great example. Couple of follow up questions.

1) The batch file calls the vbs you pointed to in your post. So I have created test.bat with the above code and dd.vbs, placed them in the same directory and ran the file. The output was: "these times are 30 to 60 minutes: ~9~0,5 ~9~0,5
following files should be the ones that qualify:" It gives the same response for every query. Am I missing something?

2) How would I specify which folder it was to look in for those files?

Thanks very much for your response, and I am making great headway.


Report •

#3
May 4, 2010 at 10:24:37
"Am I missing something?"
my mistake, probably! Lol! depending on if you caught it,
did you manage to synchronize the naming between the scripts? make sure name you saved the vbs as, and the call in the batch, are the same (i messed up and called it dd in one place, then da in another place, cause i was working on two different vbs and got them crossed up.)
if you saved the vbs as dd, make sure its like this in test.bat:
for /f "tokens=*" %%a in ('cscript /b DD.vbs %t0% -%%c') do set t%%c=%%a

If that's not the problem, try running dd.vbs from commandline and see what result:

c:\> cscript dd.vbs %time:~0,5% -30

you should obtain the current time less 30 minutes as output.
let me know and i'll try to help.

for the second query, this determines:
for %%a in (*.*) do (
you can do either of the following to set dir (f/e: photos):
pushd c:\work\photos
for %%a in (*.jpg) do (

or:
for %%a in (c:\work\photos\*.jpg)

(note i narrowed the extension to a possible .jpg, substitute if your camera generates something else.)
ps: also, due to not using miltime, there's a flaw with 12pm being gtr than 1pm. I'll see if i can fix it.


Report •

Related Solutions

#4
May 4, 2010 at 10:53:49
Excellent. Now the output from the bat+vbs is: these times are 30 to 60 minutes: PM12:17 AM11:4
following files should be the ones that qualify:
Perfectly on target. Now I just need to impliment the folder to copy from and the folder to copy to, and I will be golden. Thanks!

Report •

#5
May 4, 2010 at 11:08:48
Ok, so I created some pictures with timestamps for 12:35. It isn't detecting them when the script runs. The scripts are running in the same directory as the photos.

these times are 30 to 60 minutes: PM12:37 PM12:07
following files should be the ones that qualify:

I also added the qualifier of the directory as your example showed. It just doesn't seem to be reading the timestamps.


Report •

#6
May 4, 2010 at 12:55:44
try running it with the following "echo"s added, and post your current script?

for %%a in (*.*) do (
echo processing %%a: %%~ta
for /f "tokens=1*" %%b in ('echo %%~ta') do (
set x=%%c
set x=!x:~6!!x:~0,5!
echo X:!x!

those echos should clear up what ever is failing...
I made a new script to defeat the am/pm bug, but it runs
real slow, i think this one's faster. As it stands, though,
you'll have a "hole" at 1pm because PM12:00 is greater than
PM01:00.
You can either code in an "exception" or if you want the new version:
@echo off & setlocal enabledelayedexpansion
set t1=30
set t2=60
set t0=%time:~0,-3%
echo start time: %t0%
echo files between %t1% and %t2% minutes:
for /f "skip=5 tokens=2,3,5*" %%a in ('dir c:\work\*.*') do (
:enable the following to see rate of progress (slow!!)
:echo (testing %%c)
for /f %%z in ('cscript dd.vbs %t0% %%a%%b') do (
if %%z gtr %t1% if %%z lss %t2% echo "%%c": %%z minutes, filetime: %%a%%%b
)
)
::-------
as you can see, it' slow because it has to "dd" each file!
the other (your current) one does not.


Report •

#7
May 4, 2010 at 13:03:11
123.bat:

@echo off & setlocal enabledelayedexpansion
set t0=%time%
set t0=%t0:~0,-3%
for %%c in (30 60) do (
:: the script in the followin line does the math
for /f "tokens=*" %%a in ('cscript /b dd.vbs %t0% -%%c') do set t%%c=%%a
set test=!t%%c:~1,1!
if "!test!" equ ":" set t%%c=0!t%%c!
set t%%c=!t%%c:~9!!t%%c:~0,5!
)
echo these times are 30 to 60 minutes: !t30! !t60!
echo following files should be the ones that qualify:
pushd c:\web\new\
for %%a in (*.jpg) do (
echo processing %%a: %%~ta
for /f "tokens=1*" %%b in ('echo %%~ta') do (
set x=%%c
set x=!x:~6!!x:~0,5!
echo X:!x!
if !x! gtr !t30! if !x! lss !t60! echo %%a %%c
)
)
::------ end

Output:

C:\Web\new>123
these times are 30 to 60 minutes: 14:31 14:01
following files should be the ones that qualify:
processing Capture.JPG: 05/04/2010 02:37 PM
X:PM02:37
processing Capture1.JPG: 05/04/2010 12:35 PM
X:PM12:35
processing Capture2.JPG: 05/04/2010 12:37 PM
X:PM12:37

dd.vbs:

'(vbscript):
set xin=wscript.stdin
set cout=wscript.stdout
dim y,x
set y=wscript.arguments
a=y.count-1
if a<1 then
x=xin.readline
y=split(x)
a=ubound(y)
end if
if a<1 then
wscript.echo "add/subtract two times or dates, or add/sub units to a time or date"
wscript.echo "usage: da [units] time_or_date1 time_or_date2||number_of_units"
wscript.echo "(cap letter =default) units is one of : D w m h N s and if caps, default format output"
wscript.echo "d=days, w=weeks, m=months (applied to date), h=hours, m=minutes, s=secs (applied to time)"
wscript.quit
end if
'use colon to interpret as time, else date
p=instr(y(a-1),":")
'sets defaults for date (adjust no. days) or time (adjust no. minutes)
if p>0 then
s="n"
ff=4
else
s="d"
ff=2
end if
'now allow overrides by token #1 if valid subset
if instr("dmwhns",lcase(y(0)))>0 then
s=y(0)
'allow means for user to override formatting by using caps
if ucase(s)=s then ff=0
end if
if isnumeric(y(a)) then
test=formatdatetime(dateadd(s,y(a),y(a-1)),ff)
else
test=datediff(s,y(a),y(a-1))
end if
cout.write(test)
'END


Report •

#8
May 4, 2010 at 13:17:47
I think I may have found it, tell me what you think.

If you look in the output, it is giving 24hour time for the timestamp (i.e. 14:31 14:01) whereas the actual timestamp is in 12hour time (i.e. 02:37 PM)

Thoughts?


Report •

#9
May 4, 2010 at 13:27:16
yeah, sorry, did not know you "upgraded" to beta-release version 2.0!! Lol!
in order to get the 12-hour time you can send to dd like so:

for /f "tokens=*" %%a in ('cscript /b dd.vbs N %t0% -%%c') do set t%%c=%%a

the capital N will tell dd.vbs to format the output time like: 12:25:00 PM
the batch script handles scrambling it around to PM12:25.


Report •

#10
May 4, 2010 at 13:36:39
Output:

these times are 30 to 60 minutes: 15:04 14:34
following files should be the ones that qualify:
processing Capture.JPG: 05/04/2010 02:37 PM
X:%c
processing Capture1.JPG: 05/04/2010 12:35 PM
X:%c
processing Capture2.JPG: 05/04/2010 12:37 PM
X:%c

the X:%c is output, but I am not sure where it is cross referencing.


Report •


Ask Question