batch

Strategies for speeding up batch ORM operations in Django

One of my API calls can result in updates to a large number of objects (Django models). I'm running into performance issues with this since I'm updating each item individually, saving, and moving on to the next: for item in Something.objects.filter(x='y'): item.a="something" item.save() Sometimes my filter criterion looks like...

batch file to keep one of ten lines

I have a file with n lines. (n above 100 millions) I want to output a file with only 1 of 10 lines, I can't split the file in ten part and keep only one part, as it must be a little more random. later I have to do a statistical analysis I can't afford to create a strong bias in the data). I was thinking of reading the file and for each...

What is the best way to send an email from a batch file?

I have a nightly batch job that can tell if it has failed. I want it to send me an email, possibly with an attachment when it does. How can I send an email from a Windows Batch (.bat) file? ...

How can I feed standard input to a batch file when an app run from the batch mucks with stdin?

Here's a minimal batch file, demo.bat, to illustrate my problem: @ECHO off set /p foo=Enter foo: echo. echo you typed "%foo%" sqlcmd -? set /p bar=Enter bar: echo. echo you typed "%bar%" I have an input file foo.txt that looks like so: foo_value bar_value I run my batch file as demo.bat < foo.txt. The output is: Enter foo: y...

Finding out the file name of the running batch file

Inside a windows batch file I'd like to figgure out what the fully qualified path name of this batch file is. I tried %0 but this does only give me the typed command (e.g. just the file name without path or extension). ...

MS DOS edit a file

I am writing a batch script which I wish to open a file and then change the second line of it. I want to find the string "cat" and replace it with a value that I have SET i.e. %var% . I only want this to happen on the second line (or for the first 3 times). How would you go about doing this? ...

Pause in batch file

I am writing a batch file, in which I call an EXE to execute. Now, statements after the call to the EXE should not execute till the EXE completes its execution. How can I do it in the batch file (on Windows)? ...

How to test whether a service is running from the command line

I would like to be able to query whether or not a service is running from a windows batch file. I know I can use: sc query "ServiceName" but, this dumps out some text. What I really want is for it to set the errorlevel environment variable so that I can take action on that. Do you know a simple way I can do this? UPDATE Thank...

Get list of passed arguments in Windows batch script (.bat)

I'd like to find Windows batch counterpart to Bash's "$@" that holds a list of all arguments passed into script. Or I have to bother with "shift"? ...

Batch how to end an for-loop properly

Hi, for testing purposes i need an recursive directory with some files, that comes to maximum path-length. The Script used for the creation consists only of two for-loops, as followed: for /L %%a in (1 1 255) do @( mkdir %%a && cd %%a && for /L %%b in (1 1 %random%) do @( echo %%b >> %%a.txt ) ) Now I would li...

Issue with nested calls with psexec (access denied)

Hello First of all, sorry for my poor english. I would try to explain my problem. I am using psexec within a script to restart a cluster as follows: script1 in node1: perform a lot of tasks (shutdown services, check status, etc..) in the node1 and after completing all task launch with psexec the script2 in node2 (psexec-d \ \ node2...

Problem with for /f command on Windows XP

Hello. I'm using Windows XP Service Pack 3 and have Command Extensions enabled by default in the Windows Registry. Somehow, the following command does not work on this version of Windows but if I run it in Windows Server 2003 or Windows Vista Business, it works just fine. Any clue? The problem is that on Windows XP, it seems like the /...

Opening separate windows with Start

Hello, I am tring to open several instance of IE with the start command in a batch file. For example I want to open www.google.com and www.yahoo.com at the same time in separate windows. Any help would be appreciated. Regards, Aaron ...

How to code a spinner for waiting processes in a Batch file?

Hi there, I would like to show the user with a spinner, that something is done in background but do not know how this works in a batchfile. Does anyone have a clue? ...

Render multiple POV-Ray scenes on Windows

I have a whole bunch of POV-ray files from a molecular dynamics simulation with the general name "frameXX.pov" where "XX" is the number of the frame. I want to render them all but I have like 500 so I really don't wanna do it by hand. I'm sure there is a way to do this from the command line or a batch file...what would be the best way ...

How to read any text after = sign stored in a file.

I am working on some batch file. I need to read name from some text file. Let me explain it I have one file File.txt, which has entry like ”FirstName=John”. Now my batch file should read text ”John” from the file and I should be able store ”John” in some variable too. But with following code, If I use “delims==”,I can get ”FirstName” t...

How would I go about backing up the Windows Application Log at a regular interval?

I'm working with an application that logs to Windows Application Log regularly (viewable through the Event Viewer administrative tool), and I'm looking for a way to back it up on a daily basis. This is important because we sometimes discover a problem with the application - and to investigate further we need information that was logged a...

Detecting how a batch file was executed

Assuming Windows, is there a way I can detect from within a batch file if it was launched from an open command prompt or by double-clicking? I'd like to add a pause to the end of the batch process if and only if it was double clicked, so that the window doesn't just disappear along with any useful output it may have produced. Any cleve...

Anyone doing mainframe or AS/400 Batch processing with Java?

I'm going to propose to a client that I build some batch jobs in Java that will run on their mainframe and/or AS/400s (sorry System z and System i). Both platforms are up to date system software wise. I'm wondering if anyone has done this and can provide any pointer or gotchas to watch out for. The motivation is to have access to the to...

how to get batch file parameters from Nth position on?

Further to How to Pass Command Line Parameters in batch file how does one get the rest of the parameters with specifying them exactly? I don't want to use SHIFT because I don't know how many parameters there might be and would like to avoid counting them, if I can. For example, given this batch file: @echo off set par1=%1 set par2=%2 s...