Jump to content

Array of file dates


 Share

Recommended Posts

:idiot: I need help with the file date / count part of this

Open an ftp site / directory.

Download a dir list of filenames and filedates with mask criteria "*.xxx".

The user supplies a date which is supposed to be in the file.

Create an ftp script to download files with that date.

Create an ftp script to rename files with that date.

Execute the scripts.

I want add a sort / count of the first download to present the valid dates

to be downloaded - check the users input to ensure it was a qualifying date.

$sFtpSite = "xxx.xxx.com"

$sFtpUserID = "xxx"

$sFtpPassword = "xxx"

$sFtpDir = ".\xxx"

$sLocalDir = ".\xxx"

$sFileName1 = "ftp1.ftp"

$sLogName1 = "ftp1.log"

$sFileName2 = "ftp2.ftp"

$sLogName2 = "ftp2.log"

$sFileName3 = "ftp3.ftp"

$sLogName3 = "ftp3.log"

FileChangeDir($sLocalDir)

; offer to open the ftp site

$sAnswer1=msgbox(1,"Open FTP","Open FTP Site - " & $sFtpSite)

If $sAnswer1 = 2 Then Exit

; Create a file with ftp parameters to find file dates at the ftp site

$hFileHandle1 = FileOpen ( $sFileName1, 2 )

FileWriteline( $hFileHandle1, $sFtpUserID ) ; ftpsite userID

FileWriteline( $hFileHandle1, $sFtpPassword ) ; ftpsite password

FileWriteline( $hFileHandle1, "cd " & $sFtpDir)

FileWriteline( $hFileHandle1, "dir " & $sFtpDir & " " & $sLogName1 )

FileWriteline( $hFileHandle1, "quit" )

FileClose($hFileHandle1)

; Run ftp

RunWait(@ComSpec & " /c " & 'ftp -s:' & $sFileName1 & ' ' & $sFtpSite, "")

; select a date

$sTimeStamp = @MON & "-" & @MDAY & "-" & StringMid(@YEAR,3,2)

$sAnswer2 = InputBox("Question", "What day would you like?", $sTimeStamp)

; run the directory file to select images to download

$hFileHandle1 = FileOpen($sLogName1, 0)

If $hFileHandle1 = -1 Then

MsgBox(0, "Error", "Unable to open Input File." & @CRLF & $sLogName1)

Exit

EndIf

; Create and enter headers for ftp download parameters

$hFileHandle2 = FileOpen ( $sFileName2, 2 )

FileWriteline( $hFileHandle2, $sFtpUserID ) ; ftpsite userID

FileWriteline( $hFileHandle2, $sFtpPassword ) ; ftpsite password

FileWriteline( $hFileHandle2, "cd " & $sFtpDir)

FileWriteline( $hFileHandle2, "debug")

FileWriteline( $hFileHandle2, "type")

; Create and enter headers for ftp rename parameters

$hFileHandle3 = FileOpen ( $sFileName3, 2 )

FileWriteline( $hFileHandle3, $sFtpUserID ) ; ftpsite userID

FileWriteline( $hFileHandle3, $sFtpPassword ) ; ftpsite password

FileWriteline( $hFileHandle3, "cd " & $sFtpDir)

FileWriteline( $hFileHandle3, "debug")

FileWriteline( $hFileHandle3, "type")

$nProgress = 1

; Read in lines of text until the EOF is reached

While 1

$sLine = FileReadLine($hFileHandle1)

If @error = -1 Then ExitLoop

If StringMid($sLine, 1, 8) = $sAnswer2 And StringUpper(StringRight($sLine, 4)) = ".xml" Then

$sLine2 = "get " & StringMid($sLine, 40, 20) & " " & StringTrimRight(StringMid($sLine, 40, 20),3) & "xml"

FileWrite($hFileHandle2, $sLine2 & @CRLF)

$sLine2 = "rename " & StringMid($sLine, 40, 20) & " " & StringTrimRight(StringMid($sLine, 40, 20),3) & "xxx"

FileWrite($hFileHandle3, $sLine2 & @CRLF)

If $nProgress < 100 Then

$nProgress = $nProgress + 1

ProgressSet($nProgress)

EndIf

EndIf

If @error = 1 Then ExitLoop

Wend

; close the rename file

FileWriteline( $hFileHandle3, "quit" )

FileClose($hFileHandle3)

; close the download file

FileWriteline( $hFileHandle2, "quit" )

FileClose($hFileHandle2)

; close the read file

FileClose($hFileHandle1)

; Run ftp for the download

RunWait(@ComSpec & " /c " & 'ftp -s:' & $sFileName2 & ' ' & $sFtpSite & ' > ' & $sLogName2, "")

; Run ftp for the rename

RunWait(@ComSpec & " /c " & 'ftp -s:' & $sFileName3 & ' ' & $sFtpSite & ' > ' & $sLogName3, "")

Exit

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...