Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I automatically create a list of files and folders in a given folder in LibreOffice Calc ? I'd like it to have as much info as possible (size, name, folder hierarchy...) sorted in nice little cells. I'd rather not dump it to a file using ls and then trying to sort it manually: it creates an awful output.

share|improve this question

Your best bet would be to use a scripting language (Ruby, Python, Perl etc.) to create a text file in CSV format with this data. Calc can import CSV text files as spreadsheets.

An example Ruby script to get you started:

#!/usr/bin/env ruby
require 'csv'
table = [['Name', 'Size', 'Path']] #These are your headings - you can change them
Dir['./*'].each do |file|
    table << [File.basename(file), File.size(file), File.expand_path(file)]
    #You can add extra columns with extra information in the above line
end'output.csv', 'w') do |f|
    f.puts {|row| CSV.generate_line(row) }.join("\n")

Run this in the appropriate directory then open the file 'output.csv' with Calc. Use the following settings on the import:

calc CSV import

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.