dos-batch

Create a batch file to copy and rename file

I have little to no experience in writing batch files. I need to write one that copies a file to a new folder and renames it At the moment, my batch file consists of only this command: COPY ABC.PDF \\Documents As you can see, it only copies the file ABC.pdf to the network folder 'Documents'. However i need to change this so it renam...

Batch For /F Syntax with %time%

How do I accomplish this: for /f "tokens=1-4 delims=: " %%a in ('%time%') do set XTime=%%a.%%b.%%c.%%d I'm trying to get the contents of %time% e.g., 16:25:15.65 into 16.25.15.65. Running the command above gives me: The filename, directory name, or volume label syntax is incorrect. (If it matters I'm on Windows XP) ...

Carriagereturn(CR) to LF+CR

Hi, i want to convert CR to CR+LF in batch file. Howe can i do this by writing batch file. Please help. I am taking input from file and in that file i want to change CR to CR+LF ...

batch file + convert LF to CR+LF

HI, We have a shell script file named LineFeed.sh which does a function of converting a Linefeed(LF) to Carriage Return + LineFeed. We want the same to be done by a batch file in windows . Is it possible. Linux shell file E_WRONGARGS=65 cat OutputList|while read -r Line do if [ -z "$Line" ] then echo "Usage: `basename $0` filename-...

How to remove CR from CRLF

Possible Duplicate: Whats the best way of doing dos2unix on a 500k line file, in Windows? i have windows format*.cpp files now i want to convert it into Linux format(File with LF only) Is it possible to write a batch file. Please provide some valuable help Thanks ...

Loop issue displaying data in TXT file with BATCH programming

HI, I want to display datas in text file. Here i have Listfile.txt and want to display each line using batch file. How to do this with looping. Below is my code for /f "tokens=* delims= " %%a in (Listfile.txt) do ( set /a N+=1 set v!N!=%%a ) set hostname=!v1! echo %hostname% pause Data in Listfile.txt: 4mLinuxMachine.cpp Shutd...

How do I set the current working directory/drive in a dos batch file?

cd d:\projects does not work How can I set the current working drive and directory so that I can run msbuild scripts from there? ...

Unable to use relog to extract processor counters

When I run the following command on Windows 7 machine, relog *.blg -f csv -c "\Processor(*)\% Processor Time" -o CPUCounters.csv it returns Error: No data to return the same wildcard work when extracting PhysicalDisk counters any ideas/ suggestions? ...

How do I send an email from a DOS batch command?

I have a batch file in DOS that does some checking and I need to fire off an email when its done. I've found a few solutions on the interwebz but most of them are 3rd party or just simply open up a new message in Outlook. I need the command to send an email in its entirety without any human interaction. We use MS Exchange here, if that ...

How to move output file in dos

I would like to create a batch file which will move the output file of a custom command "mdmg C:\source i5". I must execute this command from the C:\home directory where the mdmg.cmd resides. This command converts the any file in the source dir and creates an output files in the C:\home folder. However I want to move the output files...

Spaces in batch script arguments

I have a batch script which needs to perform an action on each of its arguments. Each argument is a file name (there are not switches), and of course file names may contain spaces. The batch script is run either by dragging files into the .bat icon in Explorer or by entering the files at the command line, enclosing arguments with space...

How can I supress filename extensions at the command line interpreter and batch files?

Example: I have a file: FILENAME.EXT and would like to extract FILENAME without the .EXT I want to be able to use the extensionless filename for a command which only accepts filenames without its extensions. I have a utility called BCHECK which accepts as its argument a filename with no extensions. Using BCHECK *. does not work because a...

dos / unix programming commands with | beginners question

Hi, I'm trying to do the following: get the last line of a file: tail -n 1 test.csv if this last line is END then continue(point 3), else quit get the amount of lines in the file: wc -l test.csv put these lines in a new file without the last line: head -n (length -1) test.csv > testdone.csv (or if it's possible delete ONLY this line...

batch file directory expansion

I am trying to write a batch file that exists in an arbitrary directory and will create a new directory two levels above it. For instance, the batch file here: w:\src\project\scripts\setup.bat would create: w:\src\project.build I can't seem to figure out how to expand a path. Here is what I am currently doing: @set SCRIPT_DIR=%~dp...

Howto add a string to the 'type <filename>' DOS command before merging into file ?

Question: I've several text files containing sql create table/column/view/storedProcedure textfiles. Now I want to merge the textfiles into one textfile. I go into the directory, and type: type *.sql >> allcommands.sql Now to problem is I should add the text ' GO ' after every file's content. I can append Go by doing type *.sql >>...

syntax error on batch File to create a timestamp directory

Hi, I tried the script below to create a timestamp directory in one of my drives, for some reason is giving me a syntax error on the last string where it create the directory. See below. :: Code begins.... pause W: pause cd W:\VL2000_AMF\AMF_Archive pause for /F "tokens=1-4 delims=. " %%i in ('date /t') do ( set Day=%%i set Month=%%j se...

Batch file to copy all new files except the most recent

I would like to write a batch file containing DOS commands (unfortunately perl or another language is not an option) to do the following task. In one directory (c:\MyData\Directory1) there are the following files: File2.txt File2.dat FileA.bin FileQ.bin FileC.bin File8.bin File2.bin These files all have different creation dates. The mos...

Assigning newline character to a variable in a batch script

Hi, The following is the batch script i have written @echo off setlocal enabledelayedexpansion set finalcontent= For /F "tokens=1-2* delims= " %%I in (abc.txt) do ( IF %%J EQU MAJORVER ( set currentline=%%I %%J %1 set finalcontent=!finalcontent!!currentline! ) ELSE IF %%J EQU MINORVER ( set currentline=%%I %%J %2 set finalcontent=!fina...

Run a batch file continuously after 20 minutes (windows xp OS) ?

I want to run a batch file which contain command arp -d * ( used to flush the MAC entry table) I want to execute this batch file continuously after 20-20 minutes .. regulary ? How can i do this with batch programming ? Plz guide me .. hoping for quick and positive response .. ...

Remove an 'Equals' symbol from text string

I'm running a WMIC lookup against a series of remote client machines, pulling in Model and serial number. For /F "tokens=*" %%b in ('wmic /node:%device% computersystem get Model /value^|find "Model"') do Set model=%%b FOR /F "tokens=*" %%c in ('wmic /node:%device% bios GET serialnumber /value^|find "SerialNumber=" ') do set Seri...