From: adam beazley Date: 2005-12-30T00:59:14+09:00 Subject: Re: Directory and file listing Thanks for all of the post so far I really appreciate it. Well here is the code which I havent got to work just yet so any advice would be appreciated: #----------------------------------------------------------------------------- require 'sketchup.rb' #----------------------------------------------------------------------------- dir=gets Dir.chdir dir #Dir.chdir "c:/Program Files/@Last Software/Sketchup 5/Materials/" images=Dir["*.jpg"] images.each do |img| end def materialimporter model = Sketchup.active_model materials = model.materials if (img) # Adds a material to the "in-use" material pallet. m = materials.add "img" begin # Returns nil if not successful, path if successful. Should return a texture object m.texture=images rescue UI.messagebox $!.message end else UI.messagebox "Failure" end end if( not file_loaded?("massmaterialimporter.rb") ) # This will add a separator to the menu, but only once add_separator_to_menu("Plugins") plugins_menu = UI.menu("Plugins") Materials_menu = plugins_menu.add_submenu("Mass Material Importer") Materials_menu.add_item("Import Materials") { materialimporter } end #----------------------------------------------------------------------------- file_loaded("massmaterialimporter.rb") Ass you can see this script is meant to be put into a program called sketchup. Im trying to make sketchup create a new texture for every jpg in the given directory. Im a little confused as to how to make the program go down the list of jpg's and make a new texture for each jpg and naming that texture the same name as the jpg. ie ruby reads c://program...../.../.../sample.jpg creates a texture and names it "sample" then goes to the next jpg and does the same thing anyway thanks everyone -- Posted via http://www.ruby-forum.com/.