Copy files and folder issue

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Oldboy
Posts: 19
Joined: 09 Aug 2018, 03:03

Copy files and folder issue

29 Jul 2021, 08:37

Hi, I need to copy the CD-ROM content (files and folder) to a directory on the local hard disk.
I saw the filecopydir syntax (Copies a folder along with all its sub-folders and files (similar to xcopy), https://www.autohotkey.com/docs/commands/FileCopyDir.htm but it doesn't work...
This is my script:

FileCopyDir, E:\, C:\New folder

But when i Run the script, nothing happens... If I use FileCopy instead of FileCopyDir it works, only for the files of the main directory.
User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: Copy files and folder issue

29 Jul 2021, 08:52

Code: Select all

source = D:
target = %A_MyDocuments%\test\
If FileExist(target) {
 MsgBox, 48, Error, Target directory already exists. Aborting.`n`n%target%
 Return
} Else FileCopyDir, %source%, %target%
If ErrorLevel
     MsgBox, 48, Failure, An error occurred while copying the directory. Aborting.
Else MsgBox, 64, Success, Done!
Oldboy
Posts: 19
Joined: 09 Aug 2018, 03:03

Re: Copy files and folder issue

29 Jul 2021, 09:23

mikeyww wrote:
29 Jul 2021, 08:52

Code: Select all

source = D:
target = %A_MyDocuments%\test\
If FileExist(target) {
 MsgBox, 48, Error, Target directory already exists. Aborting.`n`n%target%
 Return
} Else FileCopyDir, %source%, %target%
If ErrorLevel
     MsgBox, 48, Failure, An error occurred while copying the directory. Aborting.
Else MsgBox, 64, Success, Done!
Thank YOU!
I don't know why it needs to create a sub folder, but it's ok for my goal.
User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: Copy files and folder issue

29 Jul 2021, 10:36

You could always write a separate routine that uses FileCopy instead, but it would require more coding (but not a lot more)!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Lamron750 and 250 guests