Trying to populate a structure inside a for loop but getting "MethodError: Cannot `convert` an object of type String to an object of type file_info"

The following

using Dates

struct file_info
       path::String
       human_time :: DateTime
       unix_time :: Float64
end

for (root, dirs, files) in walkdir(".")

    today_file_info = file_info[]

    for file in files
        filePath = joinpath(root, file);
        lastUpdatedTime = unix2datetime(stat(filePath).mtime);
        raw_time = stat(filePath).mtime
        println("=============")
        println(filePath,"   ", lastUpdatedTime, "   ", raw_time )
        println("=============")
        push!(today_file_info, file_info(filePath, lastUpdatedTime, raw_time))
    end

end

seems to work for me.

2 Likes