Sign in to follow this  
Followers 0
Systems By

Need Help with FileCopy again

8 posts in this topic

Hi everyone. I can't figure out what is wrong with my code. Here is the code I am using:

#include<File.au3>
$tempdir3=("C:\Temp\TempDir.txt")
$homepcbudir=("C:\HomeBackups\")
$bckupextdirhome=("F:\HomeBackups\")

Dim $aRecords5

ProgressOn("Automated System Maintenance", "running processes","0 percent", 555, 555)
$pbar = 15
sleep(1000)
ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Searching")
Sleep(1000)

Run("cmd.exe")

;   Wait until program active
    WinWaitActive("C:\WINNT\system32\cmd.exe")
    
$pbar = 30
sleep(1000)
ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Searching")
Send("F:{enter}")
sleep(1000)
Send("CD F:\HomeBackups{enter}")
sleep(1500)
Send("dir /a /o-d /b > C:\temp\tempdir.txt{enter}")
Sleep(1500)
Send("exit {enter}")

If Not _FileReadToArray($tempdir3, $aRecords5) Then
    MsgBox(4096, "Error", "Error reading Office PC backup log" & @error)
    Exit
    $pbar = 100
ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Process Complete")
Exit
EndIf

$pbar = 60
ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Copying Files")
For $x5 = 1 to 4
    
    If Not FileExists($bckupextdirhome &$aRecords5) Then MsgBox(64, 'Info', 'File Does not exist')
    $aRecords5[$x5] = StringStripWS($aRecords5[$x5],3)
    
$pbar = 80
ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Copying Files")
    If $aRecords5[$x5] <> "" Then
        Do
            FileMove($bckupextdirhome & $aRecords5[$x5], $homepcbudir)
           Sleep(5000)
           
            SplashTextOn("Moving",$bckupextdirhome & $aRecords5[$x5] & " to Home Backup Directory on PC", 500, 250)
            Sleep(3000)
            SplashOff()
            
            Sleep(1000)
            
        Until Not FileExists($bckupextdirhome & $aRecords5[$x5])
      ;SplashTextOn("Autobackup", "Deleting " & $home & $aRecords[$x], 200, 150)
        Sleep(200)
      ;SplashOff()
    EndIf
Next
$pbar = 100
ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Process Complete")
Sleep(5000)
ProgressOff()

If I change this line

FileMove($bckupextdirhome & $aRecords5[$x5], $homepcbudir)

to this line

FileCopy($bckupextdirhome & $aRecords5[$x5], $homepcbudir)

I only get the first file transferred then the program keeps splashing the same file over and over again and gets stuck in an infinite loop. If I move the file instead, the program works just fine.

Also, can anyone tell why this part of my code

If Not _FileReadToArray($tempdir3, $aRecords5) Then
    MsgBox(4096, "Error", "Error reading Office PC backup log" & @error)
    Exit
    $pbar = 100
ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "--> Process Complete")
Exit
EndIf

is not being seen if there is no file to read to an array? Instead, I get this error message that says: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

Any help would be appreciated.

Arvin

Share this post


Link to post
Share on other sites



Your in a loop that says to continue until the file doesn't exist anymore, when you "FileMove()", the file no longer exists, when you "FileCopy()" the original file is still there, so it continues to loop.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Welcome to the forums!

If I change this line ... to this line ...

I only get the first file transferred then the program keeps splashing the same file over and over again and gets stuck in an infinite loop. If I move the file instead, the program works just fine.

Most likely the file exists, so it won't move again (won't overwrite). Try this:

FileMove($bckupextdirhome & $aRecords5[$x5], $homepcbudir, 1)oÝ÷ Ú«¨µéÚoÝ÷ Ø l¢Ç§v)à쬶+'ßÛkyÊ&éÝyÔ¢±·­µêۺاʫq«×©emçh觢w¥wºÚ"µÍ[ØZ]
ÛÛÜXÈ   [È ÌÎNÈØÈØHÛËYØ   ÝÈ    ][ÝÉ][ÝÈ    [È ÌÍÝ[È   [È ÌÎNÉ][ÝÉÌÎNË    ÌÍØÚÝ^ÛYKÕ×ÒQJ
Good luck!

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

Thanks for your help everyone. I'll try your suggestions and post back with the results.

Share this post


Link to post
Share on other sites

This:

If Not FileExists($bckupextdirhome &$aRecords5) Then MsgBox(64, 'Info', 'File Does not exist')
should be changed to this:
If Not FileExists($bckupextdirhome & $aRecords5[$x5]) Then MsgBox(64, 'Info', 'File Does not exist')

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

This:should be changed to this:
If Not FileExists($bckupextdirhome & $aRecords5[$x5]) Then MsgBox(64, 'Info', 'File Does not exist')oÝ÷ Ûú®¢×¶¸vØb²X§zܡ׺Ú"µÍYÝ[Q^ÝÊ ÌÍØÚÝ^ÛYH [È ÌÍØTXÛÜÍVÉÌÍÞ
WJH[ÙÐÞ
    ÌÎNÒ[ÉÌÎNË   ÌÎNÑ[HÙÈÝ^Ý  ÌÎNÊ

and still get the error that says: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Any other ideas?

Share this post


Link to post
Share on other sites

I tried this line of code

If Not FileExists($bckupextdirhome & $aRecords5[$x5]) Then MsgBox(64, 'Info', 'File Does not exist')

and still get the error that says: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Any other ideas?

Where do you make an array from the string variable &aRecords5 ?

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I tried this line of code ... and still get the error that says: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Any other ideas?

Are there less than four files? That could cause you to go out of bounds.

For $x5 = 1 to 4
To move all files, use:
For $x5 = 1 to $aRecords5[0]oÝ÷ Øò¢ê',ÛhÞºháø¥zˬzØb±«­¢+Ù½ÈÀÌØíàÔôÄѼ}5¥¸ аÀÌØíI½ÉÌÕlÁt¤

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

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