Jump to content

opening some pdf files in secified interval


tko2003
 Share

Recommended Posts

Hello Group,

i have actually a small problem.

I need to open at least three pdf files, starting with the actual day and going two days to future.

The files are stored in following directory structure:

-year

-month

-pdffiles

-2008

-10

-2008-09-15.pdf, 2008-09-16.pdf and so on.

How can i open declare this in a script, that these three files are opened in intervall of 30 seconds via an PDF viewer.

I really appreciate your help on this.

Link to comment
Share on other sites

#include <Date.au3>

For $i = 0 To 2
    $TempArray = StringSplit(_DateAdd("D", $i, _NowCalcDate()), "/")
    MsgBox(0, "y", $TempArray[1]);y
    MsgBox(0, "m", $TempArray[2]);m
    MsgBox(0, "d", $TempArray[3]);d
    $path = "-" & $TempArray[1] & _
            "\-" & $TempArray[2] & _
            "\-" & $TempArray[1] & _
            "-" & $TempArray[2] & _
            "-" & $TempArray[3] & ".pdf"
    $path = "C:\whaterver" & $path
    MsgBox(0, "", $path)
    ShellExecute($path)
    Sleep(30000)
Next
remark out the msgbox lines

edit: broke up the path line for better display in the forum

edit2: changed For $i = 1 To 3 to For $i = 0 To 2

corrected slash - backslash

added path prepend

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Do I have start this from root of the directory structure?

I'm not sure I understand your question. The script can be started from any folder structure. ShellExecute will require the full path to the file of interest. I have fixed some stuff in the code I posted above and added a line for you to prepend the path.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

I'm not sure I understand your question. The script can be started from any folder structure. ShellExecute will require the full path to the file of interest. I have fixed some stuff in the code I posted above and added a line for you to prepend the path.

Sorry but i meant following structure:

-year

-month

-pdffiles

2008

10

2008-09-15.pdf, 2008-09-16.pdf and so on.

Which of the - signs i have to remove?

tko2003

Link to comment
Share on other sites

... Which of the - signs i have to remove? ...

You can change the code and see the result in the msgbox. Try this
#include <Date.au3>

For $i = 0 To 2
    $TempArray = StringSplit(_DateAdd("D", $i, _NowCalcDate()), "/")
;~     MsgBox(0, "y", $TempArray[1]);y
;~     MsgBox(0, "m", $TempArray[2]);m
;~     MsgBox(0, "d", $TempArray[3]);d
    $path = $TempArray[1] & _
            "\" & $TempArray[2] & _
            "\" & $TempArray[1] & _
            "-" & $TempArray[2] & _
            "-" & $TempArray[3] & ".pdf"
    $path = "C:\whaterver\" & $path
    MsgBox(0, "", $path)
;~     ShellExecute($path)
;~     Sleep(30000)
Next

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

You can change the code and see the result in the msgbox. Try this

#include <Date.au3>

For $i = 0 To 2
    $TempArray = StringSplit(_DateAdd("D", $i, _NowCalcDate()), "/")
;~     MsgBox(0, "y", $TempArray[1]);y
;~     MsgBox(0, "m", $TempArray[2]);m
;~     MsgBox(0, "d", $TempArray[3]);d
    $path = $TempArray[1] & _
            "\" & $TempArray[2] & _
            "\" & $TempArray[1] & _
            "-" & $TempArray[2] & _
            "-" & $TempArray[3] & ".pdf"
    $path = "C:\whaterver\" & $path
    MsgBox(0, "", $path)
;~     ShellExecute($path)
;~     Sleep(30000)
Next

Thank you again and sorry for late response, since i was sick....

okay, one little issue again, how can the script be prepared, if only one file or no file exists in the future?

and the directory structure i meaned was wrong:(

2008

2008-09

2008-10

How can i solve this?

Link to comment
Share on other sites

Sorry - I've been a bit busy elsewhere.

Try this code:

#include <Date.au3>

For $i = 0 To 2
    $TempArray = StringSplit(_DateAdd("D", $i, _NowCalcDate()), "/")
;~     MsgBox(0, "y", $TempArray[1]);y
;~     MsgBox(0, "m", $TempArray[2]);m
;~     MsgBox(0, "d", $TempArray[3]);d
    $path = $TempArray[1] & _
            "\" & $TempArray[2] & _
            "\" & $TempArray[1] & _
            "-" & $TempArray[2] & _
            "-" & $TempArray[3] & ".pdf"
    $path = "C:\whaterver\" & $path
    MsgBox(0, "", $path)
    If FileExists($path) Then
;~     ShellExecute($path)
;~     Sleep(30000)
    EndIf
Next

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...