I wrote this .BAT script, pulling snippets from all over stackoverflow about 2 years ago.
:BOF
@echo off
set upper=
set /p CDNUM=Enter NEW CD number:
set superpath=f:\prints\"CD Numbers"
for /f "skip=2 delims=" %%I in ('tree "\%CDNUM%"') do if not defined upper set "upper=%%~I"
set "upper=%upper:~3%"
ECHO.%upper% | FIND /I "CD">Nul && ( goto:Found ) || ( goto:notfind )
:Found
if exist %superpath%\17000s\%upper%\ goto ALLMADE
ECHO.%upper% | FIND /I "REV">Nul && ( goto:NEWREV ) || ( goto:norev )
:norev
md %superpath%\17000s\%upper%\"Rev -"\Cust
set ultrapath=%superpath%\17000s\%upper%\"Rev -"
copy %superpath%\START.dxf %ultrapath%
ren %ultrapath%\START.dxf "%upper% ASSEMBLY.dxf"
echo %upper% has been successfully created.
PAUSE
goto:eof
:ALLMADE
echo That CD number already exists!
PAUSE
goto:bof
:notfind
set upper="CD%upper%"
goto:Found
:NEWREV
echo Revision's not yet supported!
PAUSE
goto:bof
It prompts the user for a 'CD NUMBER', checks to make sure the folder does not already exist, creates it along with some sub directories, then copies and renames a .dxf file.
Currently the script can see if the folder already exists, returning an error message. And if only a number is given it adds a 'CD' to it, as well as making them all caps.
It's been so long since I put this together, that when I look at it I no longer remember how exactly some parts of the script work or what they do.
What I would like to add to the script is the following:
- Return an error if the input is less than 5 numbers or does not begin with '17*', 'cd17*', or 'CD17*'.
- If the input includes a 'REV' (ex. rev b), change the Rev directory accordingly. Add REV B to the filename of the .dxf (ex. CD17003 REV B ASSEMBLY)
- Common sense error checking...
This script is amazing for what it does right now, I'm just trying to improve it. Any help is greatly appreciated.