Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am using a CSV file to import users into active directory.
Example CSV:
Surname,First Name,Middle Name,Date of Birth,Student Number,Description
I can extract all the information I need using the following statement;
FOR /F "tokens=1,2,3,4,5,6* delims=," %%A IN (users.csv) DO (
That is until a field is empty, for example no middle name;
Surname,First Name,,Date of Birth,Student Number,Description
The empty value is ignored, not counted as a token which breaks my dsadd user variables.
What can I do, I am stuck!?
Thanks,

:: chg ,, to , , to keep blank fields working
@echo off > new.csv & setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (old.csv) do (
set str=%%a
set str=!str:,,=, ,!
echo !str! >> new.csv
)
=====================================
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 |