Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.

@echo off
setLocal EnableDelayedExpansion
clsdir /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

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

I'll work on it.
=====================================
If at first you don't succeed, you're about average.M2

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?

I'll work on it. Are upi sure you want semicolons?
=====================================
If at first you don't succeed, you're about average.M2

try this:
::== m4.bat
@echo off
setLocal EnableDelayedExpansion
clsdir /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

![]() |
![]() |
![]() |

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