dos

Using timestamp as unique filename

Tag(s):

Using timestamp as unique filename %date% and %time% environment variables display the date and the time respectively. These environment variables can be used to generate a relatively unique string. Here is an example:

Variable with value less than 10 placing before the redirection symbol

Tag(s):

Variable with value less than 10 placing before the redirection symbol(>>) is causing issue. That is because the end result looks like this: 1>>, 2>>, etc. Here is a good example illustrating the issue:

View memory usage of a running process

Tag(s):

@ECHO OFF
:INFINITE_LOOP
 
PING 1.1.1.1 -n 1 -w 60000 >NUL

ECHO %DATE% %TIME% doesn't work in FOR loop

Tag(s):

ECHO %DATE% %TIME% doesn't work in FOR loop. Here is an example:

Add filename, date and time at the bottom of image

Tag(s):

REM ##########################################################
REM Make a copy of the original image and then add filename, date and time at the bottom of the copy(*%suffix%).
REM This script was created because I need to know the filename of the printed image.

Open command prompt and execute some commands

Tag(s):

START cmd /k "prompt --=[$D $T]=--$_$L$P$G&& cd C:\temp\"

Clean song filename

Tag(s):

:: Description: Clean song name from an input file to <Title>-<Year>-<Artists>
:: Require: sed.exe
:: Author: Xuan Ngo
:: Version: 1.0
 
@ECHO OFF
 

Split long command over multiple lines

Tag(s):

Use caret(^). Note: Don't use space at the beginning of the appended line.

echo Hello^
World!

http://stackoverflow.com/questions/69068/long-commands-split-over-multiple-lines-in-vista-dos-batch-bat-file/21000752

Delete the oldest file using DIR /OD and EXIT

Tag(s):

The idea is to list all files by oldest date(DIR /OD) and then break out of the FOR loop on the 1st iteration using EXIT /B.

Pages

Subscribe to RSS - dos