Solved

Script to copy and name file multiple times

Posted on 2009-05-15
2
857 Views
Last Modified: 2012-06-22
I need to copy and rename one file multiple times.
Let's say the file name is StartFile.jpg
I would like to copy StartFile.jpg, rename it to
1000a.jpg
1000b.jpg
1000c.jpg
1000d.jpg
1000e.jpg
1001a.jpg
1001b.jpg
1000c.jpg
etc...all the way to 2000e.jpg

Any ideas on how to do something like that?

0
Comment
Question by:abenage
2 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 24398701
Dim fso, fil, Counter

Set fso = CreateObject("Scripting.FileSystemObject")
Set fil = fso.GetFile("c:\folder\subfolder\StartFile.jpg")

For Counter = 1000 To 2000
    fil.Copy "c:\folder\subfolder\" & Counter & "a.jpg"
    fil.Copy "c:\folder\subfolder\" & Counter & "b.jpg"
    fil.Copy "c:\folder\subfolder\" & Counter & "c.jpg"
    fil.Copy "c:\folder\subfolder\" & Counter & "d.jpg"
    fil.Copy "c:\folder\subfolder\" & Counter & "e.jpg"
Next

Set fil = Nothing
Set fso = Nothing
0
 
LVL 1

Author Closing Comment

by:abenage
ID: 31582059
Awesome!

Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now