Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i use checksum command in my batch file and the output of command as follow :

69514a29dc44cd83b42658e917ed9baf *file.txt

i want to return checksum only so i should store it in variable without file.txt like


how i can do this maybe write output of command to file then read this file ??? if yes how i can read just first 32 bits from file and store it in variable ????

share|improve this question
up vote 3 down vote accepted

You can use a sort of 'left'-function in batch:

set str=69514a29dc44cd83b42658e917ed9baf *file.txt
set str=%str:~0,32%

More info on string manipulation in dos/batch: Link

share|improve this answer
but if i want to store result from command itself how i can do this i try to do set str=checksum file.txt but not work – Mohammad AL-Rawabdeh Mar 10 '11 at 11:57
See:… – Bart De Vos Mar 10 '11 at 14:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.