BillNewB

Filecopy won't overwrite or create folder

8 posts in this topic

#1 ·  Posted

 

I thought this would be simple. This script will copy the files, as long as the dest folder already exist. If the dest folder doesn't exist, then it just creates a file with the content of the 1st log in it. Also, it won't overwrite files.

I've tried variations...

Any help would be appreciated.

FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\*.*", "c:\ck\system_info\pw_logs\", $FC_OVERWRITE + $FC_CREATEPATH) FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\*.*", "c:\ck\system_info\pw_logs\", '$FC_OVERWRITE + $FC_CREATEPATH' )
FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\*.*", "c:\ck\system_info\pw_logs\", "$FC_OVERWRITE + $FC_CREATEPATH" )

Thanks...

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi Bill,

Try this:

FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\*", "c:\ck\system_info\pw_logs\", 9 )

 

Edited by Neutro

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

The argument 9 as Neutro posted should work.

However its important to understand WHY.

Did you view the help page for the command?

https://www.autoitscript.com/autoit3/docs/functions/FileCopy.htm

And generally when sharing its best to show the variable instead of the magic number.

FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\*", "c:\ck\system_info\pw_logs\", $FC_OVERWRITE + $FC_CREATEPATH)

If you do not have it working, I would check permissions.

Perhaps elevate your script and run it as admin. 

The largest glaring issue I see, and what is probably your problem is you have your arguments encapsulated in quotes, they should not be, as then your not resolving the variable and instead just telling autoit that its a string.

Edited by ViciousXUSMC
2 people like this

Share this post


Link to post
Share on other sites

#4 ·  Posted

The reason for Neutro's 9 at the end of the script is because the two flags have been added together (1+8 = 9).

See helpfile for the flags:

$FC_OVERWRITE (1) = overwrite existing files
$FC_CREATEPATH (8) = Create destination directory structure if it doesn't exist (See Remarks).

 

You can also just use the following to copy all files into the folder:
 

FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\", "c:\ck\system_info\pw_logs\", 9)

 

 


Kind Regards
Skeletor

"I need coffee to turn me back to a normal human"

Share this post


Link to post
Share on other sites

#5 ·  Posted

These two worked:

FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\*", "c:\ck\system_info\pw_logs\", 9 )
FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\", "c:\ck\system_info\pw_logs\", 9)

Thank you all for your help. With people like you around, I feel there's still hope for the world :)

 

 

1 person likes this

Share this post


Link to post
Share on other sites

#6 ·  Posted

It will work if you use the BitXOR function on the two copy parameters:

FileCopy("c:\users\ckuser\documents\pixelwix pixelwarp evo\logs\*.*", "c:\ck\system_info\pw_logs\", BitXOR($FC_OVERWRITE, $FC_CREATEPATH))

 

1 person likes this

Who lied and told you life would EVER be fair?

Share this post


Link to post
Share on other sites

#7 ·  Posted

Where's the difference between BitXOR($FC_OVERWRITE, $FC_CREATEPATH) and $FC_OVERWRITE + $FC_CREATEPATH?
The result is in both cases 9.

Share this post


Link to post
Share on other sites

#8 ·  Posted

I don't think there is a difference to the machine. I've had good luck using the BitXOR function and then listing all parameters within, especially when opening special types of forms with specific control boxes.


Who lied and told you life would EVER be fair?

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