Computing.Net > Forums > Windows XP > CMD: Using variables in templates

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.

CMD: Using variables in templates

Reply to Message Icon

Name: blink
Date: March 19, 2007 at 03:50:09 Pacific
OS: XP
CPU/Ram: P4/1gb
Product: hp
Comment:

In my office we use CSV files to create users. In this csv file we enter the users information like his name, account, etc. Every branch of the company has different groups every users needs, so every branch has a different CSV file.

I want to create a batch file that looks in a certain directory for template csv files. The user can then choose a certain template and enter a number of variables which are used in every template. The batch file then has to fill the csv files variables and save it in a certain location.

Whats the best way to accomplish this? I was thinking of entering the variables in the template files where I want them and then somehow have the batchfile echo or type it to another file but with the variables filled with the given info.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: March 19, 2007 at 04:58:48 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion
cls

dir /b *.csv
set /p CN=which CSV?
set /p UN=user name?
set /p AN=acct num?
>> !CN!.csv echo !UN!, !AN!



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

M2



0

Response Number 2
Name: blink
Date: March 19, 2007 at 05:59:21 Pacific
Reply:

This looks good, then I use the variables !UN! etc. in the template csv?


0

Response Number 3
Name: Mechanix2Go
Date: March 19, 2007 at 08:35:40 Pacific
Reply:

It puts the vars into the selected CSV, creating it if needed. Try it.



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

M2



0

Response Number 4
Name: blink
Date: March 20, 2007 at 07:02:38 Pacific
Reply:

Is there a way to have users choose a csv by typing just a number iso the entire filename?


0

Response Number 5
Name: Mechanix2Go
Date: March 20, 2007 at 07:11:29 Pacific
Reply:

I'll work on it.


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

M2



0

Related Posts

See More



Response Number 6
Name: blink
Date: March 21, 2007 at 00:51:39 Pacific
Reply:

I set up a test rig and it doesnt quite do what I'm aiming for.

I want to create csv files like this:

Name;%Name%;Department;%Dept%;Username;!UN!

When a user chooses a csv file and enter the info I want it to export this to a new csv file on a different location. Something like this would come out:

Name;Bob;Department;Sales;Username;Bobron

Is that possible?


0

Response Number 7
Name: Mechanix2Go
Date: March 21, 2007 at 01:15:00 Pacific
Reply:

I'll work on it. Are upi sure you want semicolons?


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

M2



0

Response Number 8
Name: Mechanix2Go
Date: March 21, 2007 at 09:18:05 Pacific
Reply:

try this:

::== m4.bat
@echo off
setLocal EnableDelayedExpansion
cls

dir /b/on *.csv | find /v /n "\\"
set /p CH=choose a csv:

for /f "tokens=1-2 delims=[]" %%a in ('dir /b/on *.csv ^| find /v /n "\\" ') do (
if !CH!==%%a set CN=%%b
)

if !CN!'==' echo bad choice && goto :eof

set /p UN=user name?
set /p AN=acct num?
> !CN! type nul
>> !CN! echo user;!UN!;acct;!AN!
::==


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

M2



0

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 Windows XP Forum Home


Sponsored links

Ads by Google


Results for: CMD: Using variables in templates

Using variable in LIKE statement www.computing.net/answers/windows-xp/using-variable-in-like-statement/177856.html

Shifting variables in for /f www.computing.net/answers/windows-xp/shifting-variables-in-for-f/177632.html

Change Variable In File(win) www.computing.net/answers/windows-xp/change-variable-in-filewin/180007.html