Jump to content

Automatic editing of a batch file?


Recommended Posts

I use a lot of SVN directories for a project and thankfully each one has it's own "build.bat". What I'm trying to do is find a way to automate calling a bunch of these. The problem I'm coming across is that they each have a "pause" at the end of the file so you can view errors before it closes. I wrote up my own batch files that handles running all the needed batches and moving the results where they need to be, but I keep forgetting to sit around and watch it, so half the time I come back and it's sitting on like the second or third one waiting for me to hit a key, then I have to wait longer since it needed the input.

I know enough about PowerShell to get around with the variables and the basics, but I figured using that would give me more control of the resulting files. So what I want to accomplish is making a copy of the build.bat (in case it's updated it doesn't get broke) that is missing the pause at the end of the file.

The part I need help with is either the ability to remove all the pause commands from the runme.bat (copy of build.bat) or a way to inject all the information from build.bat (minus the pause commands) into a runme.bat.

Any help would be greatly appreciated.

Link to comment
Share on other sites


The main layout is this:

X:\
\BatchFiles (Where I'm running the PowerShell and batch scripts)
\Build (Where all the finished stuff goes)
\SVN
\Project
\1
\2
\etc

The individual Build.bat's are in the directories 1,2,etc... (I think there's like 12 total)

Not exactly sure what you mean by poison characters, but the batch files mainly just move crap around and remove the .svn directories... they also call an internal image compressor. I guess if I had to I could just move the crap around via the main PS script instead of calling all the build.bat's but I wanted to do it that way in case they change something on me.

Link to comment
Share on other sites

If you're wanting a dynamic 'copy without pause' whatever performs that task needs to be able to read and write a file containing characters which would be problematic to reproduce due to them having special meanings.

What would be needed therefore is one or more example build.bat files in order to choose an appropriate method, tool or language for performing the task.

Link to comment
Share on other sites

Most of the build.bat's follow roughly this idea...

@ECHO OFF

ECHO ------------------------------
ECHO Creating Build Folder
rmdir BUILD /S /Q
md BUILD

ECHO ------------------------------
ECHO Building Directory...
xcopy "a" "BUILD\test4\a" /E /Q /I /Y
xcopy "b" "BUILD\test4\b" /E /Q /I /Y
xcopy "c" "BUILD\test4\c" /E /Q /I /Y
xcopy "d" "BUILD\test4\d" /E /Q /I /Y
xcopy "*.xml" "BUILD\test4\" /Q /I /Y
xcopy "*.txt" "BUILD" /Q /I /Y

ECHO ------------------------------
ECHO Removing SVN directories from build...
FOR /R BUILD %%d IN (SVN) DO @RD /S /Q "%%d" 2>NUL

ECHO Build Complete - Scroll Up to check for errors.
ECHO Final build is located in the BUILD directory
ECHO Enjoy!!!

pause

Hope that helps

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...