Announcing the new Datavyu v1.3.6 with enhanced features and transcription support!

I have a print script that is written to loop over multiple files. When I run it, it loads the first file, then crashes. Here is the relevant code:

#Sets the file path of where the files are.
filedir = File.expand_path("~/Desktop/BatchAct/")
filenames = Dir.new(filedir).entries

#Begin loop over files
for file in filenames

    if file.include?(".opf") and file[0].chr != '.'

    puts "LOADING DATABASE: " + filedir+file
    $db,proj = load_db(filedir+file)
    puts "SUCCESSFULLY LOADED"

I noticed that when it gives the name of the file it just loaded, it says "LOADING DATABASE: C:/Users/Whitney/Desktop/BatchActCrawlers5.opf". The slash between the folder and the file name is missing.

asked 13 Aug '13, 10:53

WhitneyCole's gravatar image

WhitneyCole ♦
417239
accept rate: 21%


File.expand_path removes the slash from the end of the file path, so the slash needs to be added back in like this:

filedir = File.expand_path("~/Desktop/BatchAct/") + '/'
permanent link

answered 13 Aug '13, 10:54

WhitneyCole's gravatar image

WhitneyCole ♦
417239
accept rate: 21%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×46
×2
×2

question asked: 13 Aug '13, 10:53

question was seen: 2,625 times

last updated: 13 Aug '13, 10:54

powered by OSQA