# Show the filename and modified date in labels

**URL:** <https://forum.inductiveautomation.com/t/show-the-filename-and-modified-date-in-labels/19561>\
**Category:** Ignition\
**Created:** [September 6, 2018, 2:45pm UTC](https://forum.inductiveautomation.com/t/show-the-filename-and-modified-date-in-labels/19561 "2018-09-06T14:45:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rigoberto.reyes](https://avatars.discourse-cdn.com/v4/letter/r/65b543/32.png) [@rigoberto.reyes](https://forum.inductiveautomation.com/u/rigoberto.reyes)\
**Post date:** [September 6, 2018, 2:45pm UTC](https://forum.inductiveautomation.com/t/show-the-filename-and-modified-date-in-labels/19561/1 "2018-09-06T14:45:00Z")

</div>

Hello.

I need to show the filename of a document inside a folder on the network, may be using labels or another component can use, and in addition to show the modified date in another label.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 6, 2018, 3:39pm UTC](https://forum.inductiveautomation.com/t/show-the-filename-and-modified-date-in-labels/19561/2 "2018-09-06T15:39:56Z")

</div>

I’ll admit, I’m having trouble visualizing what you want to do. Are you looking to list all files in a folder, or do you already have the document and you just need to get the information for it?

---

<div class="post-metadata">

**Author:** ![rigoberto.reyes](https://avatars.discourse-cdn.com/v4/letter/r/65b543/32.png) [@rigoberto.reyes](https://forum.inductiveautomation.com/u/rigoberto.reyes)\
**Post date:** [September 6, 2018, 4:06pm UTC](https://forum.inductiveautomation.com/t/show-the-filename-and-modified-date-in-labels/19561/3 "2018-09-06T16:06:11Z")

</div>

I´m looking to list all files in a folder (\*.txt). the reason to show them incluiding the modified date is to make sure we have storaged the most recent document.

Thanks.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 6, 2018, 4:15pm UTC](https://forum.inductiveautomation.com/t/show-the-filename-and-modified-date-in-labels/19561/4 "2018-09-06T16:15:40Z")

</div>

I’d be inclined to use a table for this:

```auto
import os, time

pathName = 'c:\\Test'

# get the list of filenames
fileList = os.listdir(pathName)

headers = ['filename', 'date']
dataOut = []

for fileName in fileList:
  # getmtime returns a Unix timestamp, so we use ctime to make it more usable format.
  fileDate = time.ctime(os.path.getmtime(pathName + '/' + fileName))
  dataOut.append([fileName, fileDate])
    
filedata = system.dataset.toDataSet(headers, dataOut)

# send sorted dataset to a table-- sorted by date descending
event.source.parent.getComponent('Table').data = system.dataset.sort(filedata, 'date', 0)

```
