batch-file

how to copy a directory over another through Batch except from a specific file or file type.

Hi, I need to copy a file directory for a web site from one server to another when a change have been made i have this part working fine. But i need to copy all the file except the web.config. Is there any way in batch to copy a whole directory except a specific file or file type? Any help is appreciated. Kind Regards, Berty ...

Variable assignment problem in DOS batch file for loop

Hi, I have a variable assignment problem inside the DOS script for loop. It never assigns the value, its always blank. Below the sample code @echo off set ans=%1 SET STRING=%ans:"=% echo Parsing the string "%STRING%": for /f "tokens=1-2" %%a in ("%STRING%") do ( set Word1 =%%a echo Word 1: %%a echo Word 1: %Word1% set Word2 =%%b ...

how to get the name of the subfolder inside a known folder using batch script?

I want to fetch the names of the subfolders inside a folder using windows batch script. Can anyone pls help me out? ...

Why does appcmd.exe behave differently when executed inside a batch file?

I have the following appcmd to add an exception to IIS7's ISAPI and CGI restrictions. The exception I am adding should look like: c:\perl\bin\perl.exe "%s" %s Here is the command line: appcmd set config -section:isapiCgiRestriction "-+[path='c:\perl\bin\perl.exe \"%s\" %s', allowed='true', description='Perl CGI']" If execute this fr...

Meaning of %%~dpa ?

I am given to maintain some batch files and i repeatedly see this line in the beginning of every batch file.. FOR /f "usebackq tokens=*" %%a IN ('%0') DO SET this_cmds_dir=%%~dpa CD /d "%this_cmds_dir%" Does anyone know what the first line does? What is %%~dpa? What is %0 ? What is usebackq? ...

How can i get the file system location of a powershell script?

I have a powershell script located at d:\temp When I run this script, I want the current location of the file to be listed. How do I do this ? For example this code would accomplish it in a dos batch file; I am trying to convert this to a powershell script.. FOR /f "usebackq tokens=*" %%a IN ('%0') DO SET this_cmds_dir=%%~dpa CD /d "%...

How can I run a windows batch file but hide the command window?

How can I run a windows batch file but hiding the command window? I dont want cmd.exe to be visible on screen when the file is being executed. Is this possible? ...

programmatically executing and terminating a long-running batch process in python

Hi guys, I have been searching for a way to start and terminate a long-running "batch jobs" in python. Right now I'm using "os.system()" to launch a long-running batch job inside each child process. As you might have guessed, "os.system()" spawns a new process inside that child process (grandchild process?), so I cannot kill the batch ...

Can a batch file capture the exit codes of the commands it is invoking?

Basically, let's say that I have a batch file that calls myapp1.exe and myapp1.exe exits with Exit Code 1. Can the batch file capture this information and either force the batch file to exit with that same exit code or perform some other logic? ...

Batch command for if filename contains "X"?

I'm trying to run a batch file through a folder and delete files if their name contains a certain string. I'm not sure how to check the filename against the string though. ...

Problem with mass renaming batch file script - directories travelling

cd \. cd Source\2010 for /l %%i in (1,1,9) do ( if exist 0%%i\NUL ( cd 0%%i for /l %%j in (1,1,9) do ( if exist 0%%j\NUL ( cd 0%%j d:\Renamer\ReNamer.exe /rename "telegraf-rename" "*" cd .. ) echo 0%%i ) for /l %%k in (10,1,31) do ( if exist %%k\NUL ( cd %%k d:\Renamer\ReNamer.exe /rename "tele...

Batch - Default Browser?

Is their a way for a batch file to find the default browser on my computer? ...

iecapt utility - i am trying to get a screenshot of a site that is password protected using IECAPT, how do i pass in the creds?

I am trying to get a screenshot of a site that is password protected using IECAPT, any ideas on how I could pass in the creds? ...

is there a way to automate changing filenames in <link> , <script> tags

when we use Expires header for text files like js, css, contents are cached in the browser, to get new content we need to change in the html file the new names in the link and script tag. When we add changes. How can we automate it. In a Windows Box, I may have some bunch of html files in multiple folders also in subdirectories. There ...

Moving and renaming in batch

How to write a Batch program that can move files with .txt from a folder (including files in sub-folder) in to a different folder and rename it in the form folderName_subfolderName_Filename.extension ...

Batch file to reduce length of file name

i download file names like this.. batchengine-6099-1283555555-60054_20100910_0006.era and want to rename them to 60054_20100910_0006.era. The names change but format same, need for statement to rename of all big files ending in .era ...

Help Editing a batch file to edit a txt File

heres wat i got Script: Sub Script(Name, Major, Minor, Build, Author, Commands, Description) Name = "Recruits" Major = 2 Minor = 0 Build = 0 Author = "Youth" Commands = "" Description = "Recruits" End Sub Sub Event_Load() End Sub Sub Command_(CS) End Sub End Script: wat im trying to do is make a batch file to edit this to...

Subroutines in batch files

Given the following code: @Echo off ECHO Start ECHO Calling SUB_A CALL :SUB_A ECHO Calling SUB_B CALL :SUB_B :SUB_A ECHO In SUB_A GOTO:EOF :SUB_B ECHO In SUB_B GOTO:EOF ECHO End I expect this output: Start Calling SUB_A In SUB_A Calling SUB_B In SUB_B End But I get this: Start Calling SUB_A In SUB_A Calling SUB_...

batch file for .png?

Hi, quick question. Have a batch file that will generate a .txt file when a .png is place into the directory. Will it be possible to include the date the .png was created next to the line with a "". For example: .png "9/14/2010" .png "9/14/2010" .png "9/14/2010" right now I have this as my batch file: dir /B *.png > name.txt w...

How can I map a network drive without hardcoding a drive letter as a batch file

I need to map a network drive with a batch file, but don't want to specify the drive letter. The batch file is used as part of a deployment process; I call the batch file from CruiseControl.Net, the batch file needs to map a UNC path which requires credentials to authenticate. Then the batch file calls RoboCopy to deploy the website fro...