Jump to content

Running FileCopy with my Variables returns no errors and no results.


Go to solution Solved by ioa747,

Recommended Posts

Posted (edited)

In my code below I create variables with two paths. One contains several files (GCSaves), the other does not yet exist (backupPath).
If I run my code with 

FileCopy($fOrigin,$fDest,$FC_OVERWRITE + $FC_CREATEPATH)

nothing happens. All of the code is posted bellow, by the way. That code was given the correct variables ahead of time but does not work.

If I use 

ConsoleWrite("FileCopy("&$fOrigin&','&$fDest&",$FC_OVERWRITE + $FC_CREATEPATH)" & @CRLF)

to write my whole command out to the console. I then copy that output which looks like

FileCopy("C:\Users\Wolffe\AppData\Roaming\Dolphin Emulator\GC\USA\Card A\" , "C:\Users\Wolffe\Documents\DolphinSaves\",$FC_OVERWRITE + $FC_CREATEPATH)

If I run the above FileCopy, that I got from the ConsoleWrite, it works exactly as expected. It creates the directory and copies the files into it. I believe this means I have messed up the syntax somehow but I cannot see it. 


Relevant Bits of Code

Global $GCSaves = '"' & @AppDataDir & '\Dolphin Emulator\GC\USA\Card A\"'
Global $backupPath = '"' & @UserProfileDir & '\Documents\DolphinSaves\"'

...
...
...
...

Func funcCopy($fOrigin,$fDest)
    Switch $fOrigin
        Case "Phone"
            $fOrigin = $phonePath
        Case "PC"
            $fOrigin = $GCSaves
    EndSwitch
    Switch $fDest
        Case "Phone"
            $fDest = $phonePath
        Case "PC"
            $fDest = $GCSaves
        Case "Backup"
            $fDest = $backupPath
    EndSwitch
If MsgBox ($MB_YESNO,"Confirm Choice", "Are you sure  you want to Copy from: " & $fOrigin & " and OVERWRITE: " & $fDest) = 6 Then
    
    FileCopy($fOrigin,$fDest,$FC_OVERWRITE + $FC_CREATEPATH)
    
    ;If I use this console to write it out, I get the FileCopy command bellow that. If I run that command it works, but the command above does not
    ;ConsoleWrite("FileCopy("&$fOrigin&','&$fDest&",$FC_OVERWRITE + $FC_CREATEPATH)" & @CRLF)
    ;FileCopy("C:\Users\Wolffe\AppData\Roaming\Dolphin Emulator\GC\USA\Card A\","C:\Users\Wolffe\Documents\DolphinSaves\",$FC_OVERWRITE + $FC_CREATEPATH)
Else
    MsgBox ($MB_OK,"Pressed No","You Pressed No")
EndIf

EndFunc





Entire Script

#include <FileConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form2_1 = GUICreate("Dolphin Save Transfer Util", 498, 217, 299, 149)
$bSelectPhone = GUICtrlCreateButton("Select Phone", 32, 16, 91, 25)
GUICtrlSetTip(-1, "Select the Phone Internal Folder")
$gPhoneToPC = GUICtrlCreateGroup("Override Phone Data from PC", 8, 104, 161, 105)
$bBackupPhone = GUICtrlCreateButton("Backup", 48, 128, 75, 25)
GUICtrlSetTip(-1, "Copy Saves from Phone to Backup Location")
$bCopyToPhone = GUICtrlCreateButton("Copy", 48, 176, 75, 25)
GUICtrlSetTip(-1, "Copy PC to Phone")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$gPCToPhone = GUICtrlCreateGroup("Override PC data from Phone", 176, 104, 153, 105)
$bBackupPC = GUICtrlCreateButton("Backup", 216, 128, 75, 25)
GUICtrlSetTip(-1, "Backup PC from App Data to Backup")
$bCopyToPc = GUICtrlCreateButton("Copy", 216, 176, 75, 25)
GUICtrlSetTip(-1, "Copy Phone to PC")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$bBackupOverride = GUICtrlCreateButton("Backup Location", 32, 64, 91, 25)
GUICtrlSetTip(-1, "Default Location is in Documents Dolphin Saves")
$labelPhonePath = GUICtrlCreateLabel("Select Phone Path", 136, 24, 269, 17)
$labelBackupPath = GUICtrlCreateLabel("Default Backup Path is My Documents\DolphinSaves", 136, 72, 269, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUICtrlSetState($bCopyToPhone, $GUI_DISABLE)
GUICtrlSetState($bCopyToPc, $GUI_DISABLE)
;; To enable or disable after form created: GUICtrlSetState($bBackupOverride, $GUI_ENABLE)
;; To update Text like for a lable GuiCtrlSetdata($label, 'IT CHANGED!!!')



Global $phonePath
Global $GCSaves = '"' & @AppDataDir & '\Dolphin Emulator\GC\USA\Card A\"'
Global $backupPath = '"' & @UserProfileDir & '\Documents\DolphinSaves\"'
GuiCtrlSetdata($labelBackupPath, $backupPath)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $bSelectPhone
                funcUpdatePath("Phone")
        Case $bBackupOverride
                funcUpdatePath("Backup")
        Case $bBackupPhone
                funcCopy("Phone","Backup")
        Case $bBackupPC
                funcCopy("PC","Backup")
        Case $bCopyToPhone
                funcCopy("PC","Phone")
        Case $bCopyToPc
                funcCopy("Phone","PC")
    EndSwitch
WEnd


Func funcTestDisplay()

    MsgBox($MB_SYSTEMMODAL, "", "You chose Backup and the following files:" & @CRLF & $backupPath)

EndFunc

Func funcUpdatePath($fPathtoUpdate)

    ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
    If $fPathtoUpdate == "Phone" Then
        Local $sMessage = "Select Phone Drive, Ex SM-928U1 (E:)"
    Else
        Local $sMessage = "Select New Backup Location"
    EndIf

    ;~ My Computer location"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"

    Local $sFileSelectFolder = FileSelectFolder($sMessage, "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
    If @error Then
            ; Display the error message.
            MsgBox($MB_SYSTEMMODAL, "", "No Directory was selected.")
    Else
            ; Display the list of selected files.
            If $fPathtoUpdate == "Phone" Then
                $phonePath = $sFileSelectFolder
                ;MsgBox($MB_SYSTEMMODAL, "", "You chose Phone and the following files:" & @CRLF & $phonePath)
                GUICtrlSetState($bCopyToPhone, $GUI_ENABLE)
                GUICtrlSetState($bCopyToPc, $GUI_ENABLE)
                GuiCtrlSetdata($labelPhonePath, $phonePath)
                $phonePath = '"'&$sFileSelectFolder & 'Android\data\org.dolphinemu.dolphinemu\files\GC\USA\Card A\"'
                ;ConsoleWrite($phonePath & @CRLF)
            ElseIf $fPathtoUpdate == "Backup" Then
                Global $backupPath = $sFileSelectFolder
                GuiCtrlSetdata($labelBackupPath, $backupPath)
                ;MsgBox($MB_SYSTEMMODAL, "", "You chose Backup and the following files:" & @CRLF & $backupPath)
            EndIf
    EndIf



EndFunc


Func funcCopy($fOrigin,$fDest)
    Switch $fOrigin
        Case "Phone"
            $fOrigin = $phonePath
        Case "PC"
            $fOrigin = $GCSaves
    EndSwitch
    Switch $fDest
        Case "Phone"
            $fDest = $phonePath
        Case "PC"
            $fDest = $GCSaves
        Case "Backup"
            $fDest = $backupPath
    EndSwitch
If MsgBox ($MB_YESNO,"Confirm Choice", "Are you sure  you want to Copy from: " & $fOrigin & " and OVERWRITE: " & $fDest) = 6 Then
    
    FileCopy($fOrigin,$fDest,$FC_OVERWRITE + $FC_CREATEPATH)
    
    ;If I use this console to write it out, I get the FileCopy command bellow that. If I run that command it works, but the command above does not
    ;ConsoleWrite("FileCopy("&$fOrigin&','&$fDest&",$FC_OVERWRITE + $FC_CREATEPATH)" & @CRLF)
    ;FileCopy("C:\Users\Wolffe\AppData\Roaming\Dolphin Emulator\GC\USA\Card A\","C:\Users\Wolffe\Documents\DolphinSaves\",$FC_OVERWRITE + $FC_CREATEPATH)
Else
    MsgBox ($MB_OK,"Pressed No","You Pressed No")
EndIf

EndFunc





To further verify this and take more potential problems out of the equation I tried to simplify things in its own script with the following results.

#include <FileConstants.au3>

Local $GCSaves = '"' & @AppDataDir & '\Dolphin Emulator\GC\USA\Card A\"'
Local $backupPath = '"' & @UserProfileDir & '\Documents\DolphinSaves\"'

;Not Working
;FileCopy($GCSaves,$backupPath,$FC_OVERWRITE + $FC_CREATEPATH)

;Not Working
FileCopy('"' & @AppDataDir & '\Dolphin Emulator\GC\USA\Card A\"' , '"' & @UserProfileDir & '\Documents\DolphinSaves\"' ,$FC_OVERWRITE + $FC_CREATEPATH)

;Works Great
;FileCopy("C:\Users\Wolffe\AppData\Roaming\Dolphin Emulator\GC\USA\Card A\","C:\Users\Wolffe\Documents\DolphinSaves\",$FC_OVERWRITE + $FC_CREATEPATH)



Can any of you spot what I am clearly missing here? It seems to me that it must be a simple syntax issue but I just can't see it.

Edited by tikityler
  • Solution
Posted

 

; If you were to use a console, that would be fine.
Global $GCSaves = '"' & @AppDataDir & '\Dolphin Emulator\GC\USA\Card A\"'
Global $backupPath = '"' & @UserProfileDir & '\Documents\DolphinSaves\"'

; in Autoit (this case wants)
Global $GCSaves = @AppDataDir & '\Dolphin Emulator\GC\USA\Card A\'
Global $backupPath = @UserProfileDir & '\Documents\DolphinSaves\'

 

I know that I know nothing

Posted
9 hours ago, ioa747 said:

 

; If you were to use a console, that would be fine.
Global $GCSaves = '"' & @AppDataDir & '\Dolphin Emulator\GC\USA\Card A\"'
Global $backupPath = '"' & @UserProfileDir & '\Documents\DolphinSaves\"'

; in Autoit (this case wants)
Global $GCSaves = @AppDataDir & '\Dolphin Emulator\GC\USA\Card A\'
Global $backupPath = @UserProfileDir & '\Documents\DolphinSaves\'

 

Thank you ioa747 I thought for sure I would need to have quotes around it, and I thought it works when I put them into the FileCopy as below, so I did not think that would be the issue.
Thank you for your help. That was driving me crazy but its so simple, just like I thought it would be.
Have a great day.
 

FileCopy("C:\Users\Wolffe\AppData\Roaming\Dolphin Emulator\GC\USA\Card A\","C:\Users\Wolffe\Documents\DolphinSaves\",$FC_OVERWRITE + $FC_CREATEPATH)

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...