Search found 36 matches

by greenfinch
23 Oct 2008 09:27
Forum: DOS Batch Forum
Topic: Removing & from string
Replies: 4
Views: 5739

Quotes won't help (or hinder) here - you need setlocal enabledelayedexpansion:

Code: Select all

setlocal enabledelayedexpansion
set q=this^&that
echo %q%
set q=!q:^&=or!
echo %q%
by greenfinch
14 Oct 2008 08:15
Forum: DOS Batch Forum
Topic: xcopy "path"*.*
Replies: 2
Views: 4836

Quotes around long filenames need to enclose the whole thing:

"C:\Program Files\Debugging Tools for Windows x86)\Crash_Mode*.*"
by greenfinch
06 Oct 2008 06:27
Forum: DOS Batch Forum
Topic: Replace space with "_" in file names
Replies: 3
Views: 6964

I'm sure it's possible but my immediate thought was to use something like RenameMaster:
http://www.joejoesoft.com/cms/showpage.php?cid=108

It's free and very handy
by greenfinch
30 Sep 2008 11:00
Forum: DOS Batch Forum
Topic: Search inside a Text file and compare files in directories
Replies: 1
Views: 3897

Could you post a bit of the text file? It will be useful to see how the columns are separated.

Please post a bit within [ code ] tags
by greenfinch
30 Sep 2008 10:54
Forum: DOS Batch Forum
Topic: Extract something from a output - is this possible .?
Replies: 4
Views: 6179

This is a bit of a kludge using a temp file but it works: setlocal ipconfig | find "IP Address"> "%temp%\ipline.txt" set /p ipline=<"%temp%\ipline.txt" for /f "tokens=1-14 delims=: " %%a in ("%ipline%") DO set ipline=%%n
by greenfinch
12 Sep 2008 20:03
Forum: DOS Batch Forum
Topic: Need help creating bat for network AV program, add hostname
Replies: 12
Views: 11260

Code: Select all

echo.>>filename
echo *********>>filename
echo.>>filename



Remember, > will create a file (overwriting anything you had before) and >> appends to the file.
by greenfinch
10 Sep 2008 20:05
Forum: DOS Batch Forum
Topic: Need help creating bat for network AV program, add hostname
Replies: 12
Views: 11260

Ah, your date format is a bit different to mine - this will reformat it to YYYY-MM-DD: FOR /F "usebackq tokens=1-4,* delims=/ " %%a IN ('%date%') DO (set datestring=%%d-%%b-%%c) The tokens in your date format here are Wed 09 10 and 2008 - I ignore the first and rearrange th...
by greenfinch
10 Sep 2008 10:28
Forum: DOS Batch Forum
Topic: How do I make a variable that "counts" and saves t
Replies: 1
Views: 4232

I think the problem with a cmd script modifying itself is that the system locks the file in use. You could certainly do it with an external text file, which the batch file read in at the start, and writes out again at the end. You can use SET /a for simple counters: m This is handy to read in a text...
by greenfinch
10 Sep 2008 10:06
Forum: DOS Batch Forum
Topic: Need help creating bat for network AV program, add hostname
Replies: 12
Views: 11260

In a batch file you need %%x for tokens. If you're just typing into the comand line you need %x. So try this in the command line: FOR /F "usebackq tokens=1,2,3,* delims=/-" %a IN ('%date%') DO (set datestring=%c-%b-%a) When you put it in the script, use the original with %%...
by greenfinch
10 Sep 2008 08:17
Forum: DOS Batch Forum
Topic: Need help creating bat for network AV program, add hostname
Replies: 12
Views: 11260

Not sure - could you post the whole of your current script, with that line in it?
by greenfinch
08 Sep 2008 18:54
Forum: DOS Batch Forum
Topic: Need help creating bat for network AV program, add hostname
Replies: 12
Views: 11260

It depends what your date format is (try running date /t) but start the whole thing with something like: FOR /F "usebackq tokens=1,2,3,* delims=/-" %%a IN ('%date%') DO (set datestring=%%c-%%b-%%a) set logfile=c:\%computername%-Sophos-AV-Scan-%datestring%.log Then direct th...
by greenfinch
08 Sep 2008 18:40
Forum: DOS Batch Forum
Topic: NirCmd - handy freeware CLI tool
Replies: 0
Views: 4525

NirCmd - handy freeware CLI tool

Just found this freeware tool: m NirCmd is a small command-line utility that allows you to do some useful tasks without displaying any user interface. By running NirCmd with simple command-line option, you can write and delete values and keys in the Registry, write values into INI file, dial to your...
by greenfinch
08 Sep 2008 18:00
Forum: DOS Batch Forum
Topic: Rename multiple files
Replies: 2
Views: 4006

Code: Select all

SETLOCAL

set filecount=1
for /f %%a in ('dir /on /b *.jpg') do (call :rename %%a)
GOTO :EOF


:rename
ren %1 %filecount%.jpg
set /a filecount+=1
GOTO:EOF


This will sort by filename (dir /on) - run dir /? for other options
by greenfinch
02 Sep 2008 11:36
Forum: DOS Batch Forum
Topic: Need help creating bat for network AV program, add hostname
Replies: 12
Views: 11260

Try %computername% - see http://en.wikipedia.org/wiki/Environmen ... ft_Windows

As for the date - where do you want it? How do you want it to look (e.g. did you want something like computername-Sophos-AV-Scan-YYYY-MM-DD.log ?)
by greenfinch
19 Aug 2008 05:43
Forum: DOS Batch Forum
Topic: Handling Dates - Only checking Day and not all Date
Replies: 6
Views: 7078

This very site is as good as any for learning: m FOR help: m GOTO will go to wherever you point, then continue 'down the page'. Only usable within a file. CALL can be used within a file, but can also call other batch files: CALL :subroutine or CALL anotherbatch.cmd If used in to call a subroutine (C...