Hi,
I’m a total newb and wanted to get my hands dirty with a lil script I
could use right now.
I can get the Dir.foreach to print my directory of files separately in
irb and the rename of one existing file with it’s tag info also.
combining the two seems harder to do. Can someone please help me and
show me how to make this work together.
#!/usr/bin/ruby
require ‘taglib’
Dir.foreach("/home/music/") do |file|
Load a file
TagLib::FileRef.open (file.to_s) do |fileref|
tag = fileref.tag
also, Dir.foreach does not give the full path
so may have to append the path,
yeah some m4a files but the tag is read, I tried it with a single file
it worked with just the tag code part. so yeah I was looking at
appending the full path and tried it but strangely it does not find a
valid file.
scratching my head. I think I need to read more about the blocks and
iterators.
I’m trying to learn a bit hands on but once in a while one needs to read
a bit
end # File is automatically closed at block end
of course the error dump needed to contain the "#{tag.title}" :-[
I had copied a previous error dump by mistake from the cmd line
thanks guys that got me passed the syntax error.
hey Chris, these are the errors I get now using your code solution
TagLib: FileRef::tag() - Called without a valid file.
TagLib: FileRef::tag() - Called without a valid file.
TagLib: FileRef::audioProperties() - Called without a valid file.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.