Jump to content

Copy Multiple Files at Once..??


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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

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