I suppose if I were being lazy (ie not using xml, csv, template libraries etc and fully input/output my code) i would do something like this in ruby (available for windows and installed on most *NIX systems: Download Ruby)
Code:
csv_file = ''
# get command line args
ARGV.each do|a|
a = File.expand_path(a)
if File.exists?(a)
if File.directory?(a)
output_directory = a
else
csv_file = a
end
end
end
output_directory ||= Dir.getwd
puts "reading '#{csv_file}' file."
puts "writing to '#{output_directory}' directory."
begin
file = File.new(csv_file, "r")
while (line = file.gets)
puts "processing: #{line}"
uri, title = line.split /,/
uri.gsub!(/"/, '')
title.gsub!(/"/, '')
filename = File.join(output_directory, File.basename(uri).split('.').first + '.asx')
puts "writing ASX to #{filename}."
File.open(filename, 'w') do |out|
out.puts '<asx version = "3.0">'
out.puts ' <entry>'
out.puts " <ref href =\"#{uri}\">"
out.puts " <Title>#{title}</Title>"
out.puts ' <Author></Author>'
out.puts ' <Copyright></Copyright>'
out.puts ' <Banner></Banner>'
out.puts ' </entry>'
out.puts '</asx>'
end
end
file.close
rescue => err
puts "Exception: #{err}"
err
end That will also produce an entry for the first (header) line of the csv, but hey it's a 10 minute script, asx files are named for their media, ie 00080.wmv will generate 00080.asx.
Takes two command line arguments, one directory and one file in any order, the directory is the directory to write the asx files into (defaults to the current working directory) and the file is the csv file to read