Sign in to follow this  
Followers 0
tes5884

FileCopy Array, what am I doing wrong?

5 posts in this topic

I'm trying to copy the PST files to "C:\Backup". It created the backup folder. _ArrayDisplay shows that it successfully found the files. But it still doesn't copy the PST files..

Please tell me what I'm doing wrong.

Thanks!

$nMsg = GUIGetMsg()
Switch $nmsg
Case $bckuppst
$files = _RecFileListToArray("C:", "*.pst", 1, 0)
For $i = 1 To $files[0]
FileCopy($files[$i], "C:\Backup\", 8)
Next
EndSwitch

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You would have to include the whole path in your FileCopy, since _RecFileListToArray returns just the file name. This works for me, copying from a folder with a number of .pst files in it.

#include <RecFileListToArray.au3>
#include <Array.au3>

Local $files = _RecFileListToArray(@DesktopDir & "Test", "*.pst", 1, 0)
_ArrayDisplay($files)

For $element in $files
FileCopy(@DesktopDir & "Test" & $element, "C:PSTs", 8)
Next

Edit: obviously if you're trying to scan the entire drive for the .pst files, rather than just one or two directories, this may not be the best solution.

Edited by JLogan3o13
1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

_RecFileListToArray allows you to specify an argument to get the entire path of the files (which is probably what you want.)

Rewrite it as:

$files = _RecFileListToArray("C:", "*.pst", 1, 0, 0, 2)

And it should work as is.

Edit:

=/

Edited by mechaflash213
1 person likes this

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Or you can add the $iReturnPath value as 2 and get the full path :)

$files = _RecFileListToArray("C:", "*.pst", 1, 0, 0, 2)

This worked!

Thanks JLogan3o13 for pointing me in the right direction!

EDIT: Oops posted same time as mechaflash213, with the same result. Thanks for answering mechaflash213!

Edited by tes5884

Share this post


Link to post
Share on other sites

Ah - ha, I haven't used it in so long, I forgot about that argument. :)


√-1 2^3 ∑ π, and it was delicious!

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