// kudos: http://www.sidesofmarch.com/index.php/archive/2007/05/08/automatically-generate-partial-xml-format-files-for-bcp/ // To generate the section of my format files, I wrote the following script, which reads the first line of a text file, finds each comma, determines if it is preceded or followed by a quote, and generates the appropriate XML. //get filename var args = WScript.Arguments; if (args.length == 0) { WScript.Echo('Usage: getdelims.vbs '); WScript.Quit(); } var filename = args(0); //read file var fso = new ActiveXObject("Scripting.FileSystemObject"); var file = fso.OpenTextFile(filename,1); var contents = file.ReadLine(); file.Close(); file = null; fso = null; //find commas var cnt = 0; for (var i = 1; i < contents.length; i++) { if ( contents.substr(i,1) != ',' ) continue; cnt++; delim = ","; if ( contents.substr(i-1,1) == '"' ) delim = '",'; if ( i+1 < contents.length && contents.substr(i+1,1) == '"' ) delim += '"'; WScript.Echo('\t'); }