Jump to content
Sign in to follow this  
swstrau118

Copy files within a Network Drive.. HELP!

Recommended Posts

I am trying to copy folders from the C drive to a Network Drive and I also have to copy folders and place them in a backup folder  - is this possible? I have the following code but it doesn't appear to be working. Any help would be great!

DirCopy(@DesktopDir & "\TEST", @TempDir & "\MyTempDir", 1)
DirMove(@TempDir & "\MyTempDir", [NETWORKPATH]\Backup - " & @Year & "-" & @MON & "-" & @MDAY & "-" & @MIN &"", 1)

Share this post


Link to post
Share on other sites

as your code colouring suggests, you have a syntax error, misuse of double-quotes, and possibly variable issues.

what do you expect [NETWORKPATH] to be? it can't be a real network path.

Share this post


Link to post
Share on other sites

Hi,

Yes, that is possible.

What exactly do you type in the [NETWORKPATH] ?

What is the code exactly in that line?

Also, you dont need &"" at the end

Here is the code for the [NETWORKPATH]:

DirCopy(@DesktopDir & "\TEST", @TempDir & "\MyTempDir", 1)
DirMove(@TempDir & "\MyTempDir", "P:\TEST\Backup - " & @Year & "-" & @MON & "-" & @MDAY & "-" & @MIN &"", 1)

It does require an authentication as well. 

Edited by swstrau118

Share this post


Link to post
Share on other sites

just put another double-quote in front of P:TESTBACKUP, and delete the &"" at the end after @MIN

Share this post


Link to post
Share on other sites

just put another double-quote in front of P:TESTBACKUP, and delete the &"" at the end after @MIN

Great that worked! If I have two folders Test1 and Test2 that I am copying from C drive to the Network drive. If those two files exist is it possible to write an "If" statement to say if this Test1 and Test2 exist - rename the old files (to Test1 - 2013-07-03 or something)  Here is the code I have and I do not receive any errors it just doesn't work.

DirCopy(@DesktopDir & "\TEST", "P:\TEST", 1)
    If FileExists("Test1") AND ("Test2") Then
        FileMove("P:\TEST", "P:\TEST - " & @Year & "-" & @MON & "-" & @MDAY & "-" & @MIN &"", 1)
        EndIf

Share this post


Link to post
Share on other sites

use full absolute paths in FileExists(), and the AND condition is like this:

DirCopy(@DesktopDir & "\TEST", "P:\TEST", 1)
If FileExists("P:\Test1") AND FileExists("P:\Test2") Then
    FileMove("P:\TEST", "P:\TEST - " & @Year & "-" & @MON & "-" & @MDAY & "-" & @MIN &"", 1)
EndIf

also, your code will rename P:TEST only if both files exist, "P:Test1" and "P:Test2", it will not touch "P:Test1" or "P:Test2"

Share this post


Link to post
Share on other sites

Hmm.. I ran it and nothing happens - I do not receive any errors though. I want to try to make it rename the Test1 and Test2 if those files already exist. 

Edited by swstrau118

Share this post


Link to post
Share on other sites

I tried this code and I was able to get it to rename the Test1 folder name but it renames it as a File not a folder. Also it will not copy any of the data from the C drive, once the folder is "renamed" it seems to loose all of the text files in the previous version of the folder. Here is the code:

DirCopy(@DesktopDir & "\TEST", "P:\TEST", 1)
    If FileExists("P:\TEST\Test1") Then
        FileMove("P:\TEST\Test1", "P:\TEST\Test1 - " & @Year & "-" & @MON & "-" & @MDAY & "-" & @MIN &"", 1)
        EndIf

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  

×
×
  • Create New...