Sign in to follow this  
Followers 0
Chris_1013

FileCopy whole dir with subfolders

24 posts in this topic

I'm trying to achieve one of two things. Simply, I want to be able to copy a whole directory with all it sub-folders and files to another. I assume this is possible with the FileCopy command in AutoIt, but do you think I can work out the syntax? Can anyone give me a pointer on this?

The second thing is, I'd like to do this, but rather than getting a result at the end as to whether the whole thing completed or failed, what happened with each individual file. I assume this would work in, get a list of files in dir (and sub-dirs), copy each one, and log the result.

Can anyone get me started on this either?

Cheers

Chris

Share this post


Link to post
Share on other sites



This not so easy Larry script enumerate all folders and subfolders starting from where you want. If you modify it a little you can easily have a list of file and and folders inside two $vars. When you have this, create the folders and copy the files.

http://www.autoitscript.com/forum/index.php?showtopic=4602

Share this post


Link to post
Share on other sites

It's a pity if it's more complex. I suppose I could cheat and just call a DOS copy, but it seemed like I should be able to do it in AutoIt. I would need a search first to do file-by-file copy though.

Share this post


Link to post
Share on other sites

Why the Larry script do not help you? Sorry I dont understand. :ph34r:

Share this post


Link to post
Share on other sites

Any reason DirCopy doesn't do what you want...?

Share this post


Link to post
Share on other sites

There's a DirCopy? :ph34r:

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

DirCopy doesn't allow coping a item per time. Does it?

Edit: typo

Edited by ezzetabi

Share this post


Link to post
Share on other sites

No it doesn't, I knew I'd have to code my own solution around this, but this isn't very important as it's unlikely to fail. At first I just wanted a way to copy the whole directory, and DirCopy shall fit nicely :-)

Share this post


Link to post
Share on other sites

Grrr... Time wasted. :|

Share this post


Link to post
Share on other sites

Woah, soooooorry!!!

Share this post


Link to post
Share on other sites

Grrr... Time wasted. :|

<{POST_SNAPBACK}>

Nobody to grrr at except yourself. You could of just as easily mentioned DirCopy as I did.

Share this post


Link to post
Share on other sites

Well. I knew that DirCopy dont allow copy one item per time!

Thats why I pointed him to Larry script!

Grrrr...

And anyway, that GRRR is only a joke. Said smiling! :ph34r:

Share this post


Link to post
Share on other sites

Well. I knew that DirCopy dont allow copy one item per time!

Thats why I pointed him to Larry script!

Grrrr...

And anyway, that GRRR is only a joke. Said smiling! :ph34r:

<{POST_SNAPBACK}>

Look at what they want to do, not how they want to do it. They wanted to copy a directory. Sure, they might have wanted to do it one item at a time, but it's better to confirm that is in fact the goal by pointing out there is a better way first and seeing what the response is.

Share this post


Link to post
Share on other sites

Maybe... But it actually seems that you dont read the posts sometime.

Share this post


Link to post
Share on other sites

Maybe... But it actually seems that you dont read the posts sometime.

<{POST_SNAPBACK}>

Not Valik, you!

Did you read this sentence:

Simply, I want to be able to copy a whole directory with all it sub-folders and files to another.

Share this post


Link to post
Share on other sites

YOU AND VALIK! :ph34r:

The second thing is, I'd like to do this, but rather than getting a result at the end as to whether the whole thing completed or failed, what happened with each individual file. I assume this would work in, get a list of files in dir (and sub-dirs), copy each one, and log the result.

Share this post


Link to post
Share on other sites

Think about this for half a second ezzetabi. DirCopy() returns 1 on success, 0 on failure. There is absolutely no need to worry about each individual file and go through all that checking stuff. If a file/directory wasn't copied okay, DirCopy() will return 0 to signify failure. It would only be necessary to check each individual file if each individual file was moved via FileCopy().

Share this post


Link to post
Share on other sites

It was a Chris_1013 problem not mine. Also I thought that he/she wanted to copy each individual file for making a very detailed log where he/she could read exatly what files were missing... or who knows?

But... Who cares? Thanks Valik for solving the problem.

Next time I'll answer:

RTFM or use SEARCH! as Chris_1013 deserved since the begin!

Share this post


Link to post
Share on other sites

Ok... everybody simmer down. There was a misunderstanding and a misstating with both parties concerned, but there is no reason to go finger-pointing because both made mistakes or misstated. Laying blame will only make both (all three?) people upset, and can lead to no good end.


Who else would I be?

Share this post


Link to post
Share on other sites

RTFM or use SEARCH! as Chris_1013 deserved since the begin!

<{POST_SNAPBACK}>

Terribly sorry for the trouble I've caused you chaps. Was a simple mis-understanding. How foolish of me to assume FileCopy didn't work for directories. I wrongly assumed that a command to copy files would be all inclusive such as the 'copy' command on a command line. Simple fault of mine to miss the DirCopy commmand.

A thousand apologies for any distress caused to any of you.

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