Sign in to follow this  
Followers 0
ScriptMerchant

Parse and copy files by drive...

3 posts in this topic

Hello everyone,

I am new to AutoIt this is my first script and my first post. Im tying to make a script that can parse the drive specified (including subfolders) and copy files based on a configurable date. I believe Im close but I keep getting unknown function name from the compiler the function its complaining about it _DateDiff can anyone assist?? Here is the script :

Main()

Func Main()

Local $sPath1 = "C:"

Local $sPath2 = "24HourBackUp\"

Local $FileDate = "FileGetTime($hFile)"

Local $GFile = "_DateTimeFormat(-1)"

FileIterate($sPath1, "MyCopy")

EndFunc; Main()

Func FileIterate($sPath, $sCallback)

Local $hFile = FileFindFirstFile("C:\" & "*.doc")

If _DateDiff('D' ,$FileDate & _DateTimeFormat) = -1 Then

Call(MyCopy, $sPath1 & "\" & $sFile)

Local $sFile = FileFindNextFile($hFile)

If @error Then ExitLoop

Call($sCallback, $sPath & "\" & $sFile)

EndIf

EndFunc

Func MyCopy()

Local $sNewPath = "24HourBackUp\"; Path to copy file to

FileCopy($sPath1, $sNewPath)

EndFunc

Share this post


Link to post
Share on other sites



Hello everyone,

I am new to AutoIt this is my first script and my first post. Im tying to make a script that can parse the drive specified (including subfolders) and copy files based on a configurable date. I believe I’m close but I keep getting “unknown function name” from the compiler the function its complaining about it _DateDiff can anyone assist…?? Here is the script :

Main()

Func Main()

    Local $sPath1 = "C:"

    Local $sPath2 = "24HourBackUp\"

    Local $FileDate =  "FileGetTime($hFile)"

    Local $GFile = "_DateTimeFormat(-1)"

    FileIterate($sPath1, "MyCopy")

   

EndFunc; Main()

Func FileIterate($sPath, $sCallback)

    Local $hFile = FileFindFirstFile("C:\" & "*.doc")

    If _DateDiff('D' ,$FileDate & _DateTimeFormat) = -1 Then

Call(MyCopy, $sPath1 & "\" & $sFile)

        Local $sFile = FileFindNextFile($hFile)

        If @error Then ExitLoop

        Call($sCallback, $sPath & "\" & $sFile)

EndIf

EndFunc

Func MyCopy()

    Local $sNewPath = "24HourBackUp\"; Path to copy file to

    FileCopy($sPath1, $sNewPath)

EndFunc

<{POST_SNAPBACK}>

you need to include date.au3

In the help file for _DateDiff it reads.

#include <Date.au3> ; This is what you are missing. Place this at the top of your script

_DateDiff($sType, $sStartDate, $sEndDate)

See include in the help file for more information on including files.


Kerby

Share this post


Link to post
Share on other sites

you need to include date.au3

In the help file for _DateDiff it reads.

#include <Date.au3> ; This is what you are missing. Place this at the top of your script

_DateDiff($sType, $sStartDate, $sEndDate)

See include in the help file for more information on including files.

<{POST_SNAPBACK}>

I updated the script I dont get any error but when I run it I get a AutoIt icon in the corner that says "Script Paused" any idea what this means - theres nothing in the help file - I also tried searching the forum..?? Here is the updated script:

#include <Date.au3>

Main()

Func Main()

Local $sPath1 = "C:"

Local $sPath2 = "24HourBackUp\"

Local $search = FileFindFirstFile("C:\" & "*.doc")

Local $FileDate = FileGetTime("C:\" & "*.doc")

Local $GFile = "_DateTimeFormat(-1)"

FileIterate($sPath1, "MyCopy")

EndFunc; Main()

Func FileIterate($sPath, $sCallback)

$search = FileFindFirstFile("C:\" & "*.doc")

; Check if the search was successful

If $search = -1 Then

FileCopy("NoMatchingFilesFound", "DynamicNoMatchingFilesFound.txt")

Exit

EndIf

While 1

Local $sFile = FileFindNextFile($search)

$sDate = @MON & "/" & @MDAY & "/" & @YEAR

$sDate = $sDate -1

FileGetTime("*.doc")

If _DateIsValid( $sDate) Then

FileCopy("C:\$sDate*.doc", "$sPath2")

$file = FileFindNextFile($search)

Call($sCallback, $sPath & "\" & $sFile)

If @error Then ExitLoop

EndIf

WEnd

EndFunc; FileIterate()

Share this post


Link to post
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
Sign in to follow this  
Followers 0