creating var containing 8 random digits

November 6, 2009 at 03:40:03
Specs: Windows XP / 2003

In my batch script I need to use a wildcard or
a var accepting 8 unknown digits (e.g.

The digits are represented in the following line
as %NUMBER%.

FSUM.EXE %ark1%

In other words, i want fsum to grab a .md5 file
containing the defined var %ark1% followed by
a unknown number (8 digits)..



See More: creating var containing 8 random digits

Report •

November 6, 2009 at 04:58:02
Begin your script by coding

@echo off & setlocal EnableDelayedExpansion


set number=
for /L %%j in (1 1 8) do set number=!random:~0,1!!number!

Report •

November 6, 2009 at 05:21:29
i want fsum to grab a .md5 file
containing the defined var %ark1% followed by
a unknown number (8 digits)

for %%a in ("Z:\CHECKSUMFILES\%ark1%-*.MD5") do FSUM.EXE "%ark1%" "%%~Fa"

Report •

November 6, 2009 at 10:33:23
IVO: sorry that the title was unclear. I need, as Razor2.3 noticed, to be able to use wildcard in the fsum.exe line..

i want fsum to grab a .md5 file
containing the defined var %ark1% followed by
a unknown number (8 digits)


works! thx!

(as klint noticed, the proper fsum parameters are missing.. sorry bout the fumble..)

Report •

Related Solutions

November 6, 2009 at 10:56:15
I have no idea what you're trying to do. But it looks like I'm in good company.

Helping others achieve escape felicity


Report •

November 6, 2009 at 12:55:35
Perhaps you don't get any output because your fsum command
line is not correct? What's ark1 and why do you want to pass it
as the first argument to fsum? I would have thought you need
fsum -c *.md5.

Report •

November 6, 2009 at 14:32:59
On another note, what is FSUM?

Report •

November 7, 2009 at 00:44:36
i guess FSUM is maybe a checksum generator per file? klint seems familiar with it.

anyway, maybe simplify to derive specific objective for now,
replace vars with constants.
lets say %ark% is: A
trying to cmdline: FSUM A P\A-*.MD5

so target files are A, path (P),A,-. 8 digits, .MD5?
FSUM A P\A-12345678.MD5

and you want 8 digits betweem "A-" and "."to be
any digits (but not other than digits, no alpha etc.)
if not, can you say what variation of above configuration is your objective? (not being sarcastic, this stuff can be really hard to explain sometimes, especially with all the "special" characters and quotes!)

if you need to confirm digits only (exclude any
alpha or other):
set p=%%a : %%a is whatever var from "FOR"..
set /a p=!p!+0
if !p!>9999999 (
echo !p! qualifies for fsum)

at least i think this would work, must be tried.
that is not complete, it doesn't strip off the file extension, but that awaits further developments.


In other words, i want fsum to grab a .md5 file
containing the defined var %ark1% followed by
a unknown number (8 digits)..

Report •

November 7, 2009 at 07:03:06
this place is great! thanks for all the response..

now ill try to comment and clarify..

first of... fsum is a checksum program... creates sums and verifies etc etc...
im using fsum from slavasoft.. e.g. fsum -c -d<folder> <checksumfile>
(-c=check, -d=working dir)

in my case the folders are vars (ark1,ark2,ark3...) grabbed from a specific folder and generated in same batch (with help from IVO - see

Now, the checksumfiles are placed on network share (and connection is confirmed earlier in batch).. e.g. Z:\CHECKSUMFILES\...

Those checksumfiles are named like e.g. 00010020-20091004.MD5 (<folder>-<YYYYMMDD>.MD5)...

Now, datestamp, the last part of the checksumfile is "unknown" to batch/fsum and i would like to be able to get file using wildcard e.g. <folder>-*.MD5

As for now i removed all datestamps from checksumfiles and just using "fsum -c %ark1% Z:\CHECKSUMFILES\%ARK1%.MD5" ... and it works, but...

short intro to batch project...:
This batch is archive tester. Its used to test and verify archived folderstructures against md5 sums.
The folderstructures and the checksumfiles are kept seperate (im not allowed to place foreign objects in archived folderstructures..)
Theres continuesly new archives added, therefor the auto generation of vars, where each var (%ark%) represents a archived folderstructure.
The checksumfiles are datestamped since theres occationally correction or changes done to files within archived folderstructures.
Now I could drop the datestamp, but...

nbrane: I havent gone through your suggestions yet, will try them now and return with info..

IVO & Razor2.3:sorry for the -1.. i guess i wasnt clear enough to begin! and simply voted to get ur attention again... :D

Report •

November 7, 2009 at 07:08:44
maybe i should locate and confirm presence of checksumfile and create var... and THEN use the var, this way ill avoid using wildcards with fsum..

Report •

November 7, 2009 at 15:36:16
Take another look at Razor2.3's solution:

for %%a in ("Z:\CHECKSUMFILES\%ark1%-*.MD5") do FSUM.exe "%ark1%" "%%~Fa"

This does "locate and confirm presence of checksumfile" - it loops for as many checksum files as there are. If there is no checksum file in that folder, it will do nothing. Next problem is the way you run FSUM. Razor3.2 understandably used the same (erroneous) command-line arguments that you gave in your example. I think perhaps you should use this:

for %%a in ("Z:\CHECKSUMFILES\%ark1%-*.MD5") do FSUM.exe -c "%%~Fa"

If you get no output at all, there is no checksum file matching your specification.

By the way, for anyone wondering what this is all about, FSUM's usage can be found by googling it, as I have:

Report •

November 7, 2009 at 16:20:51
h: no need to mess with trying my suggestion as i was not correct about what i thought you were trying to do. you clarification has helped me understand the situation better. Sounds like your last comment is on the right track. If my interpretation is right, you are trying to generate a fresh checksum on the archive and compare it with an original checksum stored in z:\checksums\ named as the original directory dash datestamp? (or, currently, without the datestamp). with datestamp version, you should be able to:

setlocal EnableDelayedExpansion
cd z:\checksumfiles
for %%a in (*-*.md5) do (
set b=%%a
:put directory from fname into var. e
set e=!b:~0,8!
fsum -c !b! z:\checksumfiles\!b!)

this sounds like what you intend to do from your last comment. this uses no wildcards yet *should* pick up all the .md5 files stored in z:\checksumfiles\ named as OriginalArchiveDirectory dash datestamp dot MD5.
(if run from that directory)
if you need to generate a datestamp:
(delayed expansion on):
set z=%date%
set y=!z:~10,4!!z:~4,2!!z:~7,2!

Report •

November 8, 2009 at 10:20:02

thx ppl!

Report •

Ask Question