threeletters = "bla" shortestname = "blabla" fullname = "blabla primary school" email = "@blabla.ngfl.ac.uk" dim fs,objTextFile set fs=CreateObject("Scripting.FileSystemObject") dim arrStr set objTextFile = fs.OpenTextFile("c:\simsexports\" & shortestname & "\year3.csv") Do while NOT objTextFile.AtEndOfStream arrStr = split(objTextFile.ReadLine,",") ' arrStr is now an array that has each of your fields ' process them, whatever..... arrStr = Split(objTextFile.ReadLine,",") firstname = arrStr(0) surname = arrStr(1) pupilclass = arrStr(2) ' formatted as john smith fullnameuser = firstname & " " & surname ' formatted as john.smith fullnameuserwithdot = firstname & "." & surname ' formatted as bla.john.smith fullnameuserwithdotandthreeletters = threeletters & "." & firstname & "." & surname ' formatted as johnsmith fullnamenospace = firstname & surname ' wscript.echo fullnameuserwithdotandthreeletters DIM fso, Writethis Set fso = CreateObject("Scripting.FileSystemObject") ' define threeletters here Set Writethis = fso.CreateTextFile("c:\" & shortestname & "OUTPUT.csv", True) ' Writethis.WriteLine("DN,objectClass,sAMAccountName,mail,homemdb,displayName,company,givenName,sn,mailnickname,mDBUseDefaults,msExchHomeServerName,userPrincipalName,physicalDeliveryOfficeName") Writethis.Write ("""CN=" & fullnameuserwithdotandthreeletters & ",OU=" & fullname & " reset" & ",DC=primaryt,DC=co,DC=uk" & """") Writethis.Write (",user") Writethis.Write ("," & fullnameuserwithdotandthreeletters & "") Writethis.Write ("," & fullnameuserwithdotandthreeletters & email & "") Writethis.Write (",""CN=Mailbox Store (MAIL),CN=First Storage Group,CN=InformationStore,CN=MAIL,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=Primary Technology,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=primaryt,DC=co,DC=uk""") Writethis.Write ("," & fullnameuser & "") Writethis.Write ("," & fullname & "") Writethis.Write ("," & firstname & "") Writethis.Write ("," & surname & "") Writethis.Write ("," & fullnameuserwithdotandthreeletters & "") Writethis.Write (",TRUE,/o=Primary Technology/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=MAIL") Writethis.Write ("," & fullnameuserwithdotandthreeletters & email & "") Writethis.Write ("," & pupilclass & "") Writethis.Close Loop wscript.echo "this only does year3." objTextFile.Close set objTextFile = Nothing set fs = Nothing