File List

Description

The File List Action Component is to get a list of files that match the pattern.

Output payloadDescription
cv.PayloadOutputs the contents of the read directory as individual JSON objects.

The contents of the directory will have the following data:

For example the pattern "icons/*" might return something like this for each file:

{"IsDir":false,"ModTime":"2021-08-10T13:18:29.2577374+09:00","Name":"arrow_down.bmp","Path":"icons/arrow_down.bmp","Size":824}

DataDescription
IsDirtrue for directories, false for files
ModTimeModification Date and Time
NameFile name
PathFile path
SizeFile size

Component Properties

NameDescription
PatternThe conditional expression to list files, e.g. icons/*. Note these folders are relative to actmgr/data
IncFILESpecify whether to include files or not
IncDIRSpecify whether to include directories or not
Include Hidden Files and DirectoriesInclude hidden files in the target
Filter by Modified TimeSpecify the file filtering method. Options are as follows:
• No Filter
• Specify Time Range
• Files Older Than N Days
• Files Newer Than N Days
• Files Older Than N Hours
• Files Newer Than N Hours
• Files from Past N Days
• Files from Past N Hours
• Files from Past N Minutes
Start TimeUsed when "Specify Time Range" mode is selected. Specify the start time of the range.
End TimeUsed when "Specify Time Range" mode is selected. Specify the end time of the range.
NSpecify the value of N days/hours/minutes according to the filter mode. Used for filtering files based on modification time.
Sort OrderSpecify the sort order of search results:
• File Path (Ascending)
• File Path (Descending)
• File Name (Ascending)
• File Name (Descending)
• Modified Time (Ascending)
• Modified Time (Descending)
• File Size (Ascending)
• File Size (Descending)
Max File CountSpecify the maximum number of files to output. If 0, there is no limit.

The pattern without a file path refers to the actmgr/data folder, so all paths need to be relative to that folder. You can find more details about the paths on different operating systems here.

Note: The payload will contain the metadata for one file returned by the list each. If you follow the File List component with the Join component, you'll get a payload with every file metadata joined together. In this case, you will get:

[
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"arrow_down.bmp",
"Path":"icons/arrow_down.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"arrow_left.bmp",
"Path":"icons/arrow_left.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"arrow_right.bmp",
"Path":"icons/arrow_right.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"arrow_up.bmp",
"Path":"icons/arrow_up.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"circle.bmp",
"Path":"icons/circle.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"correct.bmp",
"Path":"icons/correct.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"downloading_f1.bmp",
"Path":"icons/downloading_f1.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"downloading_f2.bmp",
"Path":"icons/downloading_f2.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"downloading_f3.bmp",
"Path":"icons/downloading_f3.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"error.bmp",
"Path":"icons/error.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"sad.bmp",
"Path":"icons/sad.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"smile.bmp",
"Path":"icons/smile.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"zigbee_off.bmp",
"Path":"icons/zigbee_off.bmp",
"Size":824
},
{
"IsDir":false,
"ModTime":"2017-12-14T17:23:11+08:00",
"Name":"zigbee_on.bmp",
"Path":"icons/zigbee_on.bmp",
"Size":824
}
]

Example: Uploading Captured Photo Files to Google Drive Automatically

action-file-list-upload-google-drive-1

Use the List component to get the array of images

action-file-list-upload-google-drive-2

The upload component will iterate through the files. Read in the Google Drive Upload component how to authenticate with Google Drive.

action-file-list-upload-google-drive-3

Delete the images in the folder after upload.