# How to read file date information

**URL:** <https://discourse.nodered.org/t/how-to-read-file-date-information/51706>\
**Category:** General\
**Created:** [30 September 2021 07:13 UTC](https://discourse.nodered.org/t/how-to-read-file-date-information/51706 "2021-09-30T07:13:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![yfhzs](https://avatars.discourse-cdn.com/v4/letter/y/87869e/32.png) [@yfhzs](https://discourse.nodered.org/u/yfhzs)\
**Post date:** [30 September 2021 07:13 UTC](https://discourse.nodered.org/t/how-to-read-file-date-information/51706/1 "2021-09-30T07:13:47Z")

</div>

Hi  
I am using node red to try to read the date information of the file and determine whether the file exceeds the storage period.everybody have a solution？ thank you

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 September 2021 07:36 UTC](https://discourse.nodered.org/t/how-to-read-file-date-information/51706/2 "2021-09-30T07:36:36Z")

</div>

try this

```auto
[{"id":"63aae358.20b5d4","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ls -l new1.csv | cut -d \" \" -f5","payloadType":"str","x":120,"y":4480,"wires":[["aa74a8a7.d9a218"]]},{"id":"ae4ef9b4.4bd328","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":4280,"wires":[]}]

```

change the filename and its path. in the inject node.  
This should return the size alone.

```auto
ls -l filename | cut -d " " -f5

```

---

<div class="post-metadata">

**Author:** ![yfhzs](https://avatars.discourse-cdn.com/v4/letter/y/87869e/32.png) [@yfhzs](https://discourse.nodered.org/u/yfhzs)\
**Post date:** [30 September 2021 07:50 UTC](https://discourse.nodered.org/t/how-to-read-file-date-information/51706/3 "2021-09-30T07:50:22Z")

</div>

Thank you for your answer. This method is not applicable to my project. I need to process the file according to the returned information. Thank you again for your answer.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 September 2021 08:29 UTC](https://discourse.nodered.org/t/how-to-read-file-date-information/51706/4 "2021-09-30T08:29:48Z")

</div>

> [@yfhzs](#):
>
> This method is not applicable to my project.

Why not? What information do you want about the file?

---

<div class="post-metadata">

**Author:** ![yfhzs](https://avatars.discourse-cdn.com/v4/letter/y/87869e/32.png) [@yfhzs](https://discourse.nodered.org/u/yfhzs)\
**Post date:** [30 September 2021 08:38 UTC](https://discourse.nodered.org/t/how-to-read-file-date-information/51706/5 "2021-09-30T08:38:38Z")

</div>

Hello, what I need is the date information of the file.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [30 September 2021 08:39 UTC](https://discourse.nodered.org/t/how-to-read-file-date-information/51706/6 "2021-09-30T08:39:48Z")

</div>

Install node-red-contrib-fs-ops

It has a selection of nodes, one of them can get attributes of a file.

---

<div class="post-metadata">

**Author:** ![yfhzs](https://avatars.discourse-cdn.com/v4/letter/y/87869e/32.png) [@yfhzs](https://discourse.nodered.org/u/yfhzs)\
**Post date:** [30 September 2021 08:42 UTC](https://discourse.nodered.org/t/how-to-read-file-date-information/51706/7 "2021-09-30T08:42:59Z")

</div>

Thank you for your answer ,Let me test it.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 September 2021 13:09 UTC](https://discourse.nodered.org/t/how-to-read-file-date-information/51706/8 "2021-09-30T13:09:01Z")

</div>

```auto
ls -l filename | cut -d " " -f 6,7,8

```

would give you the date and time

---

<div class="post-metadata">

**Author:** ![yfhzs](https://avatars.discourse-cdn.com/v4/letter/y/87869e/32.png) [@yfhzs](https://discourse.nodered.org/u/yfhzs)\
**Post date:** [1 October 2021 12:04 UTC](https://discourse.nodered.org/t/how-to-read-file-date-information/51706/9 "2021-10-01T12:04:47Z")

</div>

Thank you for your answer e1cid, Like one day in September, I can define it as day.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [30 November 2021 12:05 UTC](https://discourse.nodered.org/t/how-to-read-file-date-information/51706/10 "2021-11-30T12:05:08Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
