FileInfo (previously GetModDate) - get some information about files and folders e.g. modified date

(Robert Crum) #1


:point_up:As you know, it is possible with the shell component to get the modified date
However sometimes a directory contains a lot of files and the ls -l command crashes from about more than 600-700 files. I wanted something which has no crashes or lags so I wrote this very simple extension:
GetModDate
It is a faster and better solution to get modified date.

Blocks what you can use:
blocks

How to use extension:
Here is an example (remember that it works both with files and folders, not just one of them!):


Your path mustn’t start with file://
As you can see, you don’t have to write “/” after the folder name.
If the object does not exist or it’s modified date is not accessible, it will return to the devices “zero” time (which is not actually zero but the system can’t think of time e.g. before 1970).

Download: com.robertcrum.GetModDate.aix (6.1 KB) It should work on all Android devices from 4.4.

Testing

Android 4:


Android 5:

Android 6:

Android 7:

Android 8:

Android 9:

8 Likes
(MeteorCoder) #2

If this is your first extension Robert, good job!!!

2 Likes
(Daniel) #3

You learn English, not I do…
However, fine extension. By the way, I knew you were doing this all in a GitHub repo, below GPL, or now you don’t want to make it?

EDIT: found another typo/issue

If I’m true, it’s spelled as contain, but I’m not certain, Nathan or Cian, you’re the essential English speakers I know around there, can you verify it?

(Yusuf Cihan) #4

Good job Robert for the first extension! :+1::slightly_smiling_face:


By the way, @Daaniiieel I didn’t understand why you want to fix Robert’s grammar errors. :sweat_smile:

I know, I’m not an essential English speaker but just checked for you in grammar checker. :joy:

image
(not sponsored don’t worry :rofl:)

2 Likes
(Daniel) #5

Because he’s my brother :joy:

1 Like
(Robert Crum) #6

UPDATE

Added new blocks. With this extension now you can…

  • Get modified date

  • Format modified date. For example MM/dd/yyyy HH:mm:ss will return 10/10/2020 12:34:34.
    Screenshot_2019-03-25_15-36-38
    (It supports many formats.)

  • Get file length (size in bytes)

  • Get content list from a folder (which contains both files and folders, with only their name: command.txt, data) It working fast: loading 4000 items took only 1-2s, it doesn’t lag.

  • Check if the file/folder exist

  • Check if the given path is a directory

It’s functions:

This extension is no longer just a modifieddate-extension. New name is: FileInfo
Download: com.robertcrum.FileInfo.aix (8.1 KB)

1 Like
#7

thank you for your contribution
you might want to follow the naming conventions, which is UpperCamelCase for property, method and event names (i.e. the first letter should be a capital letter) and lowerCamelCase for parameter names

example:
naming

rather than having a method name like isExist let me suggest you to rename it to Exists

Taifun

3 Likes
(Robert Crum) #8

Corrected the mistakes. Sorry for not providing image. Extension: com.robertcrum.FileInfo.aix (8.1 KB)

3 Likes
(Robert Crum) #9

New version is here!

Added some blocks:

  • ExecuteLinuxCommand : run linux commands with result.

Example:

  • GetFileList: Get only the files from a directory, with names.

  • GetFolderList: Get only foders from a directory, with names.

(Why don’t I put containsPath property to them? Because of there are no subdirectories’ files contained, you can easily make the full paths with join block [join(path + name)]. For subdirectories, use your logic or Taifun’s File extension.)

  • GetName: Returns to the name of the file from its path. For example /system/app/AutoDialer will return AutoDialer. Works with files and folders too.

Here are the blocks (sorry for that low quality):

Download: com.robertcrum.FileInfo.aix (10.3 KB)

As you can see, it is 4,2 KB larger than the first version (what stands for 110 new lines of code)

4 Likes
(Robert Crum) #10

Added protection against non-readable folders (like /cache). They were causing an error “Attempt to get length of a null array”. Created another block to check if a folder is accessible (for files use this with parent folder):
ablocks
Download extension: com.robertcrum.FileInfo.aix (10.6 KB)

2 Likes