Jump to content
Sign in to follow this  

Weird and probably stupid problem with DirCopy

Recommended Posts


Hello everyone!

I'm writing an installer for my application that does a backup at a certain point. I'm writing AutoIT code since 3 years, and I really can't figure out why this line doesn't work.

DirCopy(@ScriptDir, @ScriptDir & "\MWBackup", 1)

I feel REALLY stupid, that's so simple! :S

For some reason it creates the Directory but it doesn't copy files in it. Can you help me please? It works as intended with ANY other source folder.

Edited by Kingpix

Share this post

Link to post
Share on other sites

I guess the target directory is created first and then the function tries to copy that into itself...

#include <File.au3>
Local $s_TempDir = _TempFile(@TempDir, "~", "", 7)
DirCopy(@ScriptDir, $s_TempDir & "\", 1)
DirRemove($s_TempDir & "\MWBackup\", 1) ; to avoid recursion during backup (taking a backup of the old backup)
DirCopy($s_TempDir & "\", @ScriptDir & "\MWBackup\", 1)
DirRemove($s_TempDir, 1)

Share this post

Link to post
Share on other sites

Thanks for the input, but I realized there is another problem.

The @ScriptDir macro returns "E:", which is the root of the E HDD. And that's correct, but after doing some research I found out that DirCopy doesn't work with HDD roots. :(

Share this post

Link to post
Share on other sites

Even though, it seems weird to copy something inside itself.

Edit: If this last does not work you can do a recursive copy, there may be some examples on the forum (e.g: _RecFileListToArray combined with FileCopy) ;).

Br, FireFox.

Edited by FireFox


OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control


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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.