Jan-Erik R.
3/1/2009 3:14:00 PM
Harry Nash schrieb:
> Thanks for your reply, I had read the doc but could not get it to work
> This is what I wound up doing and it does work.
>
> Dir.chdir("e:/foldertest")
> artist = 'Abba'
> artist_check = Dir.glob("#{artist}", File::FNM_CASEFOLD)
> puts artist_check
> if "#{artist}" != "#{artist_check}"
> puts "no match found"
> else puts "found match"
> end
>
Dir.glob returns an array, not a string, so your "if artist !=
artist_check" will fail.
also, you won't find folders/files like "abba album" with your search,
if you want this add the star ("*")
artist is already a string, so no need for "#{...}", just use artist
and at last:
if you changed the if-construct it will fail, if Dir.glob found "abba",
because your "artist" is "Abba" ;)