Jump to content
Sign in to follow this  
cypher175

Copy Multiple Files at Once..??

Recommended Posts

cypher175

Is there anyway to Copy Multiple Files at Once..??

do these functions copy files one at a time or multiple files at once "FileCopy" & "DirCopy"..??

What I want to do is Search a Folder or Drive for all its Files + SubContents then copy multiple files from that Src to one Dest Folder at once..

But instead of mirroring the Folder or Drive i Just want to Copy all the files over into one single folder and append the Current Date + Time to each file copied over..

So in one Dest Folder I'll have all the Src files with the Time+Dates appended to each of them..

But my main concern is just copying multiple files at once like 10 files at a time..

How would I go about doing something like this..??

Share this post


Link to post
Share on other sites
Xenobiologist

You could try using the commandline (DOS) with Run or Shellexecute (maybe ...Wait) and start n instances of xcopy.


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
cypher175

is there any other way that doesn't involve using external executables like xcopy..??

Share this post


Link to post
Share on other sites
Yashied

If I understand you correctly, it should look something like this:

#Include <File.au3>
#Include <WinAPIEx.au3>

_DirCopyEx(@WindowsDir, @ScriptDir & '\---JPG---', '*.jpg')

Func _DirCopyEx($sSrc, $sDest, $sMask = '*')

    Local $FileList, $FileName, $Time, $Path, $Name, $Ext, $Count

    $FileList = _FileListToArray($sSrc, $sMask, 1)
    If Not @error Then
        For $i = 1 To $FileList[0]
            $Time = '[' & _WinAPI_GetDateFormat(0, 0, 0, 'dd-MMM-yy') & ' & ' & _WinAPI_GetTimeFormat(0, 0, 0, 'h-mm') & ']'
            $Name = StringRegExpReplace($FileList[$i], '\.[^.]*$', '') & ' ' & $Time
            $Ext = StringRegExpReplace($FileList[$i], '^.*\.', '')
            $Path = $sDest & '\' & $Name & '.' & $Ext
            $Count = 2
            While FileExists($Path)
                $Path = $sDest & '\' & $Name & ' (' & $Count & ').' & $Ext
                $Count += 1
            WEnd
            If Not FileCopy($sSrc & '\' & $FileList[$i], $Path, 8) Then
                Return 0
            EndIf
        Next
    EndIf
    $FileList = _FileListToArray($sSrc, '*', 2)
    If Not @error Then
        For $i = 1 To $FileList[0]
            If Not _DirCopyEx($sSrc & '\' & $FileList[$i], $sDest, $sMask) Then
                Return 0
            EndIf
        Next
    EndIf
    Return 1
EndFunc   ;==>_DirCopyEx

WinAPIEx.au3

Edited by Yashied

Share this post


Link to post
Share on other sites
cypher175

does that code copy more than 1 file at time..??

Share this post


Link to post
Share on other sites
Yashied

Share this post


Link to post
Share on other sites
cypher175

copying multiple files at once instead of one at a time is multihreading..??

Share this post


Link to post
Share on other sites
Yashied
cypher175

I dont mean like in a magic split instant all yer files are copied..

I mean instead of copping one file after the other one at a time, copy 10 files at a time simultaneously..!!!

Share this post


Link to post
Share on other sites
Pain

They are basically copied right after each other, unless you have several threads making it "appear" as they were copied simultaneously.

Share this post


Link to post
Share on other sites
Yashied

I mean instead of copping one file after the other one at a time, copy 10 files at a time simultaneously..!!!

This does not happen. You can verify this yourself by running to copy the folder in Windows. Moreover, the simultaneous copying a few files will be much slower, because the HDD can not simultaneously write multiple data streams. Edited by Yashied

Share this post


Link to post
Share on other sites
Steveiwonder

I would use something like...

;Your program.exe

Local $FileToCopy[4]

$FileToCopy[0] = "file1.txt"
$FileToCopy[1] = "file2.txt"
$FileToCopy[2] = "file3.txt"
$FileToCopy[3] = "file4.txt"

For $i = 0 To Ubound($FileToCopy)-1 Step +1

    Run("doCopy.exe """ & $FileToCopy[$i] & """ """ & "C:\test\" & $FileToCopy[$i] & """")
Next

doCopy.exe

;cmdline[1] contains source
;cmdline[2] contains destination
FileCopy($CmdLine[1],  & $CmdLine[2])

This will work however attempting to do what you want will seriously slow down your computer due to the fact your hard disk is being over worked(if you do to many). Stick to using the normal method :mellow: It works much better.

Steveiwonder.

Edited by Steveiwonder

They call me MrRegExpMan

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.