Jump to content

FileCopy Array, what am I doing wrong?


Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

_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
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.”

 

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...