Computing.Net > Forums > Programming > Batch script: Help with FOR file IO

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch script: Help with FOR file IO

Reply to Message Icon

Name: stephenturns
Date: November 30, 2006 at 04:24:14 Pacific
OS: Windows XP SP2
CPU/Ram: P4 / 1GIG RAM
Comment:

Hi,
I want to store variables in a temp file and to be able to call those variables for usage in the batch file.

Im not sure how to manipulate the FOR command for this. I want to be able to store variables in that temp file and also I want to be able to search the temp file for the variable.

My plan for the temp file is as follows:
------
VARIABLES:
INT1: VAR1
INT2: VAR2
CHAR1: VAR3
CHAR2: VAR4
------
Any help regardless of the FOR command usage would be greatly appreciated.
Thanx for you help :)



Sponsored Link
Ads by Google

Response Number 1
Name: tonysathre
Date: December 1, 2006 at 11:38:07 Pacific
Reply:

I noticed you are using int and char datatypes. Batch scripts do not use special datatypes and are not defined in the script.

"Computer security." — Oxymoron


0

Response Number 2
Name: stephenturns
Date: December 1, 2006 at 12:54:24 Pacific
Reply:

Thanx for your comments tonysathre,
The datatypes are only for my reference. When i create a local variable within a batch script i like to be as discriptive as possible. It just lets me know what the variable is used for throughout the script.


0

Response Number 3
Name: Mechanix2Go
Date: December 2, 2006 at 00:05:38 Pacific
Reply:

Is your goal to set, for instance:

INT1=VAR1

?


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 4
Name: stephenturns
Date: December 2, 2006 at 03:49:34 Pacific
Reply:

Mechanix2Go,
A better example than the one above would be:
---%temp%\~atempfile.tmp
VARIABLES
Date=%date%
Time=%time%
Name=%stringName%
---
I want to store variables, from batch file execution, into a temp file and call those variables back into the batch file when requested.
Im having trouble putting the variables where I would like them to go, for example the variables %stringName% to be placed after the Name= in the temp file.
Im also having trouble storing those variable values into "fresh" variables in the batch script.


0

Response Number 5
Name: Mechanix2Go
Date: December 2, 2006 at 11:37:55 Pacific
Reply:

With those lines in myfile.tmp you can:

for /f "tokens=*" %%V in (%TEMP%\myfile.tmp) do set %%V

BTW, reassigning built-in vars lije TIME and DATE is generally not a good idea.


=====================================
If at first you don't succeed, you're about average.

M2



0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch script: Help with FOR file IO

Batch Script Help and Suggestions www.computing.net/answers/programming/batch-script-help-and-suggestions/14552.html

Batch Script To FTP a file www.computing.net/answers/programming/batch-script-to-ftp-a-file/17008.html

Batch Script Help Needed www.computing.net/answers/programming/batch-script-help-needed/14475.html