Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy files

Status
Not open for further replies.

abenitez77

IS-IT--Management
Oct 18, 2007
147
US
I have a file called Claim1.pdf. I want to make 50 copies of this file starting from claim51.pdf to claim100.pdf

How can i do this ?
 
Here's a solution using DOS commands if you like:

for /L %i in (51,1,100) do copy claim1.pdf claim%i.pdf
 
Always good to know more than 1 way to skin a cat. Thanks!
 
Hey I might have the right solution to your problem and it comes in one script too. take a look at the code below. copy it and paste it then run it. you definitely want to specify your own parameters

1. create a new folder in your desktop and name it "new"
2. in that folder create a plain-text file in notepad and name it "this"
3. change "C:\Users\bryan\Desktop\new" to the desktop path of your system, using your username NOT mine

Option Explicit
Dim fso, msg, strfolder, container, i, filename

msg = "file: " & filename & " will be copied 50 times" & vbNewLine

strfolder = "C:\Users\bryan\Desktop\new"

filename = "C:\Users\bryan\Desktop\new\this.txt"

Set fso = WScript.CreateObject("Scripting.FileSystemObject")


For i = 1 To 50
fso.GetFile(filename).Copy strfolder & "\" & "this" & i & ".txt", True
Next


 
My previous code had some minor glitches here is a revised and improved version, check it out

Option Explicit
Dim fso, msg, strfolder, container, i, filename

strfolder = "C:\Users\bryan\Desktop\new"

filename = "C:\Users\bryan\Desktop\new\this.txt"

msg = "file: " & "''"&filename&"''" & " will be copied 50 times" & vbNewLine

Set fso = WScript.CreateObject("Scripting.FileSystemObject")

MsgBox msg,vbOKOnly + vbInformation, "copying file 50 times"
For i = 1 To 50
fso.GetFile(filename).Copy strfolder & "\" & "this" & i & ".txt", True
Next

Set fso = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top