Jump to content

How to copy a folder and subfolders and files from a network drive to a PC?


Recommended Posts

I've been trying to figure out how to copy a folder and subfolders and files from a network drive to a PC using a batch file, but everything I tried is not working.

I would like first for the script to check the local PC and if a certail folder exists already, to delete it first and then copy the desired folder from a network drive to the local PC. I'm trying to keep this simple, as I'm new to scripting.

Any advice would be much appreciated.

Thanks,

Dan

Link to comment
Share on other sites

I've been trying to figure out how to copy a folder and subfolders and files from a network drive to a PC using a batch file, but everything I tried is not working.

I would like first for the script to check the local PC and if a certail folder exists already, to delete it first and then copy the desired folder from a network drive to the local PC. I'm trying to keep this simple, as I'm new to scripting.

Any advice would be much appreciated.

Thanks,

Dan

I use something like this to backup my data from my "library" drive, to a backup drive.

xcopy source dest

e.g. - xcopy g:\library f:\bkup /E /C /F /H /R /Y > f:\bkup\xcopy.log

all directories, ignore errors, display full filename, do hidden+system files, overwrite RO files, no prompt and output details to xcopy.log.

More complex tasks can be done - e.g. exclusion lists - do a dir /s > your_file if you want to exclude all files under a certain directory, then pass "your_file" as an exclusion list. Date is also useful - if your backups are weekly, then you only need to copy everything in the last week etc.

You should have gotten that G:\ F:\ can be networked drives if you like. You can script adding those, but it's better to just leave em up on startup.

Try help xcopy for more info.

Hope that helps,

Beomagi

Link to comment
Share on other sites

Thanks so much, I got it, but I will incorporate some of your suggestions into mine to make it more reboust.

Thanks

Dan

I use something like this to backup my data from my "library" drive, to a backup drive.

xcopy source dest

e.g. - xcopy g:\library f:\bkup /E /C /F /H /R /Y > f:\bkup\xcopy.log

all directories, ignore errors, display full filename, do hidden+system files, overwrite RO files, no prompt and output details to xcopy.log.

More complex tasks can be done - e.g. exclusion lists - do a dir /s > your_file if you want to exclude all files under a certain directory, then pass "your_file" as an exclusion list. Date is also useful - if your backups are weekly, then you only need to copy everything in the last week etc.

You should have gotten that G:\ F:\ can be networked drives if you like. You can script adding those, but it's better to just leave em up on startup.

Try help xcopy for more info.

Hope that helps,

Beomagi

Link to comment
Share on other sites

  • 2 months later...

I didn't want to start a new thread, and i had trouble finding an answer... but...

Im writing a script that finds all the folders on a network drive and lists them into a listview.

I tested to see if it works on a local drive, which it does, but retrieving from the network drive, it fails.

How would i go about doing this?

- i was using the file list array function. to list all folders.

TIA

Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

I didn't want to start a new thread, and i had trouble finding an answer... but...

Im writing a script that finds all the folders on a network drive and lists them into a listview.

I tested to see if it works on a local drive, which it does, but retrieving from the network drive, it fails.

How would i go about doing this?

- i was using the file list array function. to list all folders.

TIA

So tell us your meaning of "it fails" (empty result, error message...?). And: Showing your code makes it much easier to help.

AJag

Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Link to comment
Share on other sites

So tell us your meaning of "it fails" (empty result, error message...?). And: Showing your code makes it much easier to help.

AJag

sorry...

nothing shows up. empty listview...

no errors...

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

I tried this, and it works all (local drive, network path and mapped network drive):

#Include <File.au3>
#Include <Array.au3>

; --- Local Dir:

$FileList=_FileListToArray("D:\","*",2)
If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
_ArrayDisplay($FileList,"$FileList")

; --- Network path:

$FileList=_FileListToArray("\\DS207p\transfer","*",2)
If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
_ArrayDisplay($FileList,"$FileList")

; --- Network mapped drive

$FileList=_FileListToArray("W:\","*",2)
If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
_ArrayDisplay($FileList,"$FileList")

Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

Link to comment
Share on other sites

#Include <File.au3>
#Include <Array.au3>

; --- Network mapped drive

$FileList=_FileListToArray("W:\","*",2)
If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
_ArrayDisplay($FileList,"$FileList")

im away from my computer, but what does the 2 mean?

and thank you

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

im away from my computer, but what does the 2 mean?

and thank you

Right from the F1-Help of "_FileListToArray":

_FileListToArray($sPath[, $sFilter = "*"[, $iFlag = 0]])

$iFlag=0(Default) Return both files and folders

$iFlag=1 Return files only

$iFlag=2 Return Folders only

AJag

Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

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