Jump to content
Gringo

Dircopy and variables

Recommended Posts

Gringo

Hi,

I'd like to do simple copy of a directory reading an ini for the path.

I'm pretty sure it's not a big deal but for a noob like me... Well I'm looking for a solution since 2 hours now :)

 

#include <MsgBoxConstants.au3>
$dircp = IniRead("path.ini", "Path", "path", " ERROR")

MsgBox($MB_SYSTEMMODAL, "", "path is: : " & $dircp)
DirCopy ("Guideone", $dircp)

The value returned by iniread is correct, but the dircopy does nothing,

 

Any idea? :)

Share this post


Link to post
Share on other sites
Subz

After DirCopy add a MsgBox with @error to determine the error.  Also try to use pathname @ScriptDir & "\GuideOne" for your first parameter (assuming "GuideOne" is in the same folder as the script.

Share this post


Link to post
Share on other sites
Gringo

Thank you for your answer, I'll try that :) but the synthax with the

& $dircp

seems correct right?

Edited by Gringo

Share this post


Link to post
Share on other sites
Subz

Syntax looks correct, normally I would write the script like so, it's basically the same as your script except with some error handling, hope it makes sense.

Local $sSrcPath = @ScriptDir & "\Guideone"
    If FileExists($sSrcPath) = 0 Then Exit MsgBox(16, "Error", "Source File: " & $sSrcPath & " doe's not exist.")
Local $sTgtPath = IniRead(@ScriptDir & "\Path.ini", "Path", "Path", "Error")
    If $sTgtPath = "Error" Then Exit MsgBox(16, "Error", "Error Reading Ini.")

Local $hDirCopy = DirCopy ($sSrcPath, $sTgtPath, 1) ;~ Flag 1 means overwrite existing folder
    If $hDirCopy = 1 Then
        MsgBox(64, "Success", "Copied:" & @CRLF & @TAB & $sSrcPath & @CRLF & " To: " & @CRLF & @TAB & $sTgtPath)
    Else
        MsgBox(16, "Failure", "Error Copying:" & @CRLF & @TAB & $sSrcPath & @CRLF & " To: " & @CRLF & @TAB & $sTgtPath)
    EndIf

 

Share this post


Link to post
Share on other sites
Gringo

Thank you very much again, It says that the folder is copied exept it doesn't, maybe It's a bug with dircopy

I tried to compile it and run it as administrator with no success.

Maybe  I can try to do the same thing runing a command like

xcopy guideone "F:\Jeux\Steam\SteamApps\common\Fallout 4\guideone" /s /y /I

but passing the destination dir as variable

something like

#include <MsgBoxConstants.au3>
$dircp = IniRead("path.ini", "Path", "path", " ERROR")
Run(@ComSpec & " /c " & "xcopy ", & "guideone " &$dircp & " /s" " /y" " /I", "", @SW_HIDE)

I'll test that, what do you think?

Edited by Gringo

Share this post


Link to post
Share on other sites
Melba23

Gringo,

You appear not to have read the Forum rules since your arrival. Please do read them - particularly the bit about not discussing game interaction - before you post again and then you will understand why you will get no help and this thread will now be locked.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Similar Content

    • Progh0st
      By Progh0st
      This peace of code does not work. I'm trying to copy all my usb files to desktop. What is wrong with it?
      DirCopy("E:", @DesktopDir & "\Backups\MyWork", $FC_OVERWRITE) ;Tried also this, not working. DirCopy("E:\", @DesktopDir & "\Backups\MyWork\", $FC_OVERWRITE)  
    • gillesg
      By gillesg
      Hi all,
      I need to make a dircopy function that correctly handle symlink and junction without duplicating files and folder.
      Let's try to be more precise
      I have the following directory structure 
      My folder---+ | |-- Local.file (regular file) |-- local folder (regular folder) |-- Target.symlink (symlink to file Local.file) |-- target.folder.symlink (symlink to folder local.folder) |-- target.folder.junction (junction to folder D:\PAC_Launchers\test\local.folder) 22/03/2016 21:42 10 Local.file 22/03/2016 21:41 <REP> local.folder 22/03/2016 21:42 11 Target.file 22/03/2016 21:40 <REP> Target.folder 22/03/2016 15:16 <JONCTION> target.folder.junction [D:\PAC_Launchers\test\local.folder] 22/03/2016 15:15 <SYMLINKD> target.folder.symlink [local.folder] 22/03/2016 07:42 <SYMLINK> Target.symlink [Local.file] To do so, i need to be able to identify that a file or a folder is a Symlink or Junction. And in that case I need to know the target of the symlink or junction.
      Does any of you have an idea or a script to do so.
      Gilles
       
    • Monica
      By Monica
      Hi Guys!
      I'm trying to copy a folder from location A to location B. The DirCopy embedded function works great, but if the folder is large, my little program freeze, so that the user doesn't understand what's going on. I've found many solutions in this forum, but not for me.
      So... All I want to do is delegate to someone the folder copy process... To Windows, obviously!
      The API is a good solution I found... _WinAPI_CopyFileEx works like a charm, but it is for files only! I tried to insert a folder (with or without final /), but fails.
      Is there an API functions for me? Please... help me!

      Reg.
      Monica
      PS
      Attached code from help (_WinAPI_CopyFileEx)
       
      prova.au3
×