Posted by Anonymous on Mon 25th Jan 05:10 (modification of post by view diff)
download | new post
- #!/usr/bin/ruby
- #
- # copy a playlist to a dir
- unless ARGV.size == 2
- $stderr.puts "usage: #{$0} file.pls dest"
- exit -1
- end
- pls, dst = ARGV[0,1]
- fd=File.open(pls)
- args={}
- $stderr.puts fd.readline # header
- while (arg=fd.readline) !~ /^NumberOfEntries=/
- name, value = arg.split(/=/)
- args[name]=value
- end
- p args
- pls_size = arg[/=(.*)/,1].to_i
- files=[]
- fd.each_line do |line|
- name=line[/File\d+=(.*)$/,1]
- files << name
- end
- if files.size != pls_size
- $stderr.puts "warning: playlist size was #{files.size}, but expected #{pls_size}"
- end
- File.open("/tmp/foo","w") do |of|
- of.print files.join(0.chr)
- end
- dst="/tmp/bar"
- IO.popen("rsync --files-from=- -0 -PnavzS --stats /home/irish/ #{dst}","w") do |of|
- of.print files.join(0.chr)
- end
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.