Script or batch to copy and rename files

Need a script or batch to copy a file and rename it, looping X number of times. For instance, I have a file named 180816.SKD. I need to copy that file and rename to 180817.SKD, 180818.SKD, etc. In order to eliminate not having to mess with dates, I could simply start with 180801.SKD and the script could loop through 30 times, naming each copy advancing 01 (180801.SKD) through 31 (180831.SKD).
murrycAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewCommented:
Not sure if I completely understand, but this should get you started, adjust as needed.

@echo off
setlocal EnableDelayedExpansion

set CopyFile=180816.SKD
set DestDir=c:\temp

for /l %%i in (1,1,30) do (
    set Day=0%%i
    set Day=!Day:~-2!
    copy "%CopyFile%" "%DestDir%\1808!Day!.SKD"
)

Open in new window

When run this would perform the following copies:

copy "180816.SKD" "c:\temp\180801.SKD"
copy "180816.SKD" "c:\temp\180802.SKD"
copy "180816.SKD" "c:\temp\180803.SKD"
copy "180816.SKD" "c:\temp\180804.SKD"
copy "180816.SKD" "c:\temp\180805.SKD"
copy "180816.SKD" "c:\temp\180806.SKD"
copy "180816.SKD" "c:\temp\180807.SKD"
copy "180816.SKD" "c:\temp\180808.SKD"
copy "180816.SKD" "c:\temp\180809.SKD"
copy "180816.SKD" "c:\temp\180810.SKD"
copy "180816.SKD" "c:\temp\180811.SKD"
copy "180816.SKD" "c:\temp\180812.SKD"
copy "180816.SKD" "c:\temp\180813.SKD"
copy "180816.SKD" "c:\temp\180814.SKD"
copy "180816.SKD" "c:\temp\180815.SKD"
copy "180816.SKD" "c:\temp\180816.SKD"
copy "180816.SKD" "c:\temp\180817.SKD"
copy "180816.SKD" "c:\temp\180818.SKD"
copy "180816.SKD" "c:\temp\180819.SKD"
copy "180816.SKD" "c:\temp\180820.SKD"
copy "180816.SKD" "c:\temp\180821.SKD"
copy "180816.SKD" "c:\temp\180822.SKD"
copy "180816.SKD" "c:\temp\180823.SKD"
copy "180816.SKD" "c:\temp\180824.SKD"
copy "180816.SKD" "c:\temp\180825.SKD"
copy "180816.SKD" "c:\temp\180826.SKD"
copy "180816.SKD" "c:\temp\180827.SKD"
copy "180816.SKD" "c:\temp\180828.SKD"
copy "180816.SKD" "c:\temp\180829.SKD"
copy "180816.SKD" "c:\temp\180830.SKD"

Open in new window


»bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
murrycAuthor Commented:
Great work, as always Bill!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.