Jump to content

Recommended Posts

Posted

I am looking for a way to create multiple .asx wrapper files from a csv file or similar.

 

I have taken a science dvd that consists of many clips and converted it into separate short clips that are then placed onto a Windows Streaming Server and accessed from anywhere on site via the Learning Platform. This works fine when performing individual convertions, but for multiple files it is a time consuming activity creating the individual asx wrapper files.

 

The wrapper file is the small file that is placed on the learning environment that effectively makes the content searchable and referencable on the Sharepoint Learning Platform. Example below.

 

the nativity story

 

I would like to be able to create multiple files based upon a csv file that contains the mms address of the media and also the Title for the media. The title also becomes the filemane for each newly created asx file. Example below. Has anyone heard of such a thing of are there any coders that would like to spend a couple of hours knocking together a command line c# application, powershell or similar application to fill the neiche?

 

 

mmsreference,title

"mms://MEDIA01/videos/0081.wmv","the nativity story"

"mms://MEDIA01/videos/0080.wmv","L'esquive"

 

Many thanks,

 

Martin Byford-Rew

IT Manager

Thomas Deacon Academy

Peterborough

Posted (edited)

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)

 

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 ''
     out.puts '  '
     out.puts "    "
     out.puts "    #{title}"
     out.puts '    '
     out.puts '    '
     out.puts '    '
     out.puts '  '
     out.puts ''
   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

Edited by Chillibear
added note about output filenames

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...