Sign in to follow this  
Followers 0
theguy0000

What is wrong with this script?

7 posts in this topic

#include <File.au3>
Dim $file,$backupfile,$backupfilename,$trash
For $i=1 To $CmdLine[0]
    $file = $file & " " & $CmdLine[$i]
Next
$file = StringTrimLeft ($file, 1)
If $file = "" Then exit
$path = _PathSplit ($file, $trash, $trash, $trash, $trash)
$backupfile = _TempFile (@HomeDrive & "\BACKUP\", "", $path[4])
$filename = $path[3] & $path[4]
If FileCopy ( $file, @TempDir & "\BACKUP\", 9 ) = 0 Then
    MsgBox (48, "AutoBackup File Backup Utility", "AutoBackup failed to copy "&$file&" to "&@TempDir & "\BACKUP\" & $filename&".")
    Exit
EndIf
$backupfilename = _PathSplit ($backupfile, $trash, $trash, $trash, $trash)
$backupfilename = $backupfilename[3] & $backupfilename[4]
If FileMove ( @TempDir & "\BACKUP\" & $filename, $backupfile ) = 0 Then
    MsgBox (48, "AutoBackup File Backup Utility", "AutoBackup failed to move " & @TempDir & "\BACKUP\" & $filename & " to "_
    & $backupfile & ".")
    exit
EndIf
If IniWrite ( @HomeDrive & "\BACKUP\settings.ini", "Files", $backupfilename, $file ) = 0 Then
    MsgBox (48, "AutoBackup File Backup Utility", "AutoBackup could not write to the settings.ini file because it is read-only. Backup h_
as failed.")
    FileDelete ( $backupfile )
    Exit
EndIf
MsgBox (64, "AutoBackup File Backup Utility", "AutoBackup has successfully added "&$filename&" to your weekly backup. Please note that _
the file has not actually been backed up yet, only added to your computer's backup directory. This file, along with the rest of your bac_
kup directory, will be backed up at the designated automatic backup day.")

I run this program with the parameters:

C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Blue hills.jpg

and i get:

What am I doing wrong?


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites



#include <File.au3>
Dim $file,$backupfile,$backupfilename,$trash
For $i=1 To $CmdLine[0]
    $file = $file & " " & $CmdLine[$i]
Next
$file = FileGetShortName (StringTrimLeft ($file, 1))
If $file = "" Then exit
$path = _PathSplit ($file, $trash, $trash, $trash, $trash)
$backupfile = _TempFile (@HomeDrive & "\BACKUP\", "", $path[4])
$filename = $path[3] & $path[4]
If FileCopy ( $file, @TempDir & "\BACKUP\", 9 ) = 0 Then
    MsgBox (48, "AutoBackup File Backup Utility", "AutoBackup failed to copy "&$file&" to "&@TempDir & "\BACKUP\" & $filename&".")
    Exit
EndIf
$backupfilename = _PathSplit ($backupfile, $trash, $trash, $trash, $trash)
$backupfilename = $backupfilename[3] & $backupfilename[4]
If FileMove ( @TempDir & "\BACKUP\" & $filename, $backupfile ) = 0 Then
    MsgBox (48, "AutoBackup File Backup Utility", "AutoBackup failed to move " & @TempDir & "\BACKUP\" & $filename & " to "_
    & $backupfile & ".")
    exit
EndIf
If IniWrite ( @HomeDrive & "\BACKUP\settings.ini", "Files", $backupfilename, $file ) = 0 Then
    MsgBox (48, "AutoBackup File Backup Utility", "AutoBackup could not write to the settings.ini file because it is read-only. Backup h_
as failed.")
    FileDelete ( $backupfile )
    Exit
EndIf
MsgBox (64, "AutoBackup File Backup Utility", "AutoBackup has successfully added "&$filename&" to your weekly backup. Please note that _
the file has not actually been backed up yet, only added to your computer's backup directory. This file, along with the rest of your bac_
kup directory, will be backed up at the designated automatic backup day.")

still doesnt work :lmao:


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

what am i doing wrong?


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Did you try to debug it?

If FileExists((@TempDir & "\BACKUP\" & $filename) Then 
    MsgBox(0, 'Exists', 'File does Exist')
Else
    MsgBox(0, 'Does Not Exist', 'The File Does Not Exist')
EndIf

Put that before the filemove.

Edited by SmOke_N

[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

hmm...the file doesnt exist...what could i be doing wrong that would not allow it to copy, and the copy error doesn't pop up...


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

Put a msgbox in your loop:

For $i=1 To $CmdLine[0]
    $file = $file & " " & $CmdLine[$i]
    MsgBox(0, 'Files', $file); watch this because you have no seperator here, and if you have more than one file, they are going to all be on one line.
Next

[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

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