Solved How do you rename a folder sequentially.

March 13, 2015 at 10:09:27
Specs: Windows 7
Multiple times a day we copy a template folder with many sub folders in it and then rename it the next number in the sequence. Template folder is 15-P0000. the rename is the next number after the last folder number, eg. 15-P0256.

I am new to writing batch files and I can't seem to find out how to accomplish this.

Ant help would be greatly appriciated.

Jeff Brown


See More: How do you rename a folder sequentially.

Report •


#1
March 13, 2015 at 23:11:43
✔ Best Answer
::====== script starts here ===============
::
:: nameci.bat 2015-03-14 12:54:54.47
@echo off & setLocal enableDELAYedeXpansioN

set/p SRC=where your files are

for /L %%i in (256 1 999) do (
if not exist Y:\15-P0%%i (
xcopy /s/c/v/h/r/e !SRC!\*.* Y:\15-P0%%i\
goto :donecopy
)
)
:donecopy
goto :eof
::====== script ends here =================

=====================

M2 Get custom script or take private lessons


Report •

#2
March 14, 2015 at 09:51:03
Thanks Mechanix2Go!!!!! That is exactly what I was looking for!!!! Buying some batch books today to help in the learning process.

Thanks again,
nameci


Report •

#3
March 14, 2015 at 16:08:43
If you're still picking a language, I suggest picking up one of the better languages. VBScript is more compatible across Windows versions, and significantly more structured. PowerShell is the Hot New Thing™, and has a Windows native ISE to help you write your scripts.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
March 14, 2015 at 20:20:38
Take my seminar. Buy my book. LOL

=====================

M2 Get custom script or take private lessons


Report •

#5
March 16, 2015 at 05:56:09
Thanks for the advice!!

Report •

#6
March 19, 2015 at 00:49:34
Hi R2,

I looked at a few vbs tutorils. Thay had the msg box, buttons etc, which I don't need.

Got one which does just text?

=====================

M2 Get custom script or take private lessons


Report •

#7
March 19, 2015 at 07:39:27
Honestly, I'm not a good resource for training materials, since I'm self taught from the MS reference. I'd imagine your best bet would be looking for tutorials focused on Windows administrators, since those should be more interested in showing work getting done.

The biggest question is which script host you are using. Natively, you have a choice of CScript, WScript, and Internet Explorer. (Run: cscript //? or wscript //? to see how to change the engine.)

Other than that, for output I tend to use WScript.Echo, since that'll show a message box if you use WScript.exe, or it'll spit out the text to console if you're using CScript.exe.

How To Ask Questions The Smart Way


Report •

#8
March 19, 2015 at 20:42:18
Hi R2,

Why am I not surprised you're self taught.

I'll keep hunting for a tut.

=====================

M2 Get custom script or take private lessons


Report •


Ask Question