tko2003 Posted October 22, 2008 Posted October 22, 2008 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.
herewasplato Posted October 22, 2008 Posted October 22, 2008 (edited) #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) Nextremark 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 October 22, 2008 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
tko2003 Posted October 22, 2008 Author Posted October 22, 2008 Do I have start this from root of the directory structure?
herewasplato Posted October 22, 2008 Posted October 22, 2008 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]
tko2003 Posted October 23, 2008 Author Posted October 23, 2008 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-pdffiles2008102008-09-15.pdf, 2008-09-16.pdf and so on.Which of the - signs i have to remove?tko2003
herewasplato Posted October 24, 2008 Posted October 24, 2008 ... 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]
tko2003 Posted October 30, 2008 Author Posted October 30, 2008 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?
herewasplato Posted November 7, 2008 Posted November 7, 2008 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]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now