Hi
Is there a method to massively output file properties into a list?
I am a lecturer. When grading my students’ assignments recently, I noticed that some students handed in other students’ work with few modifications. I could check the file property of each file to see if the file was created and last modified by the same user individually, though since there are 320 models it would take forever to check each file.
Is it possible for me to output file properties of all files into a table so that I can compare the creator and last modified user, or is there a better method for me to check the originality of my student’s assignment?
Thanks.
This sounds like an OS scripting question, or maybe not even that. You can look into exposing and outputting file properties in the file browser. It should be possible to export file properties to a spreadsheet for further processing if you need.
For example, for Windows, here’s an approach using Excel: Redirecting
Write a Python script in Rhino that iterates over all 3dm files in a given folder and uses File3dm.Read Method. Then you can access File3dm Properties like File3dm.Created Property and File3dm.CreatedBy Property . You also may want to iterate over the File3dm.Objects Property and compare object IDs. If your students created their assignments from scratch there should be no matching IDs between files.
thanks. with your’s and chatpgt’s help, I solved the issue and this was the solution:
import os
import Rhino
import scriptcontext
import datetime
import codecs # Explicitly import the codecs module
def iterate_3dm_files(folder_path, output_file):
# Open the output file in write mode with UTF-8 encoding
with codecs.open(output_file, ‘w’, encoding=‘utf-8’) as file:
# Ensure the folder exists
if not os.path.exists(folder_path):
file.write(“Error: The folder {} does not exist.\n”.format(folder_path))
return
# Iterate over all files in the folder
for filename in os.listdir(folder_path):
# Check if file has .3dm extension
if filename.lower().endswith(".3dm"):
file_path = os.path.join(folder_path, filename)
file.write("Processing file: {}\n".format(filename))
try:
# Read the .3dm file
rhino_file = Rhino.FileIO.File3dm.Read(file_path)
# Access general properties
created = rhino_file.Created
created_by = rhino_file.CreatedBy
# Write file properties to output file
file.write("File: {}\n".format(filename))
file.write(" Created: {}\n".format(created))
file.write(" CreatedBy: {}\n".format(created_by))
# Iterate over objects in the file
LastEdited = rhino_file.LastEdited
LastEdited_by = rhino_file.LastEditedBy
file.write(" LastEdited: {}\n".format(LastEdited))
file.write(" LastEditedBy: {}\n".format(LastEdited_by))
except Exception as e:
file.write("Error reading {}: {}\n".format(filename, e))
Define your folder path and output file path here
folder_path = r"G:\work\2025\3dm" # Replace with your actual folder path
output_file = r"D:/testresult.txt" # Specify the output file path
Call the function to process the files and write the output to the file
iterate_3dm_files(folder_path, output_file)