FileInfo - get some information about files and folders

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:)

4 Likes

Because he’s my brother :joy:

2 Likes

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

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

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

3 Likes

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

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

The block ExecuteLinuxCommand did not work properly. Commands with ’ or " in them returned to empty string and did nothing. Like cp -r ‘/system/app’ ‘/mnt/sdcard/system apps’ or echo “hello world”.

Now it has been fixed! Download extension: com.robertcrum.FileInfo.aix (10.7 KB)

Source-code of that block
View code

@SimpleFunction(description = “Execute a linux command. You can also use this for file options e.g. cp - copy mv - move rm - remove. Example: cp -r ‘/system/app’ ‘/mnt/sdcard/My Documents/systemapps’”)
public String ExecuteLinuxCommand(String command){
String s;
Process p;
String result = “”;
try {
p = Runtime.getRuntime().exec(new String{“sh”,"-c",command});
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((s = br.readLine()) != null)
result = result + s + System.lineSeparator();
p.waitFor();
p.destroy();
} catch (Exception e) {}
return result;
}

Why do I publish that? Because finding the right way take me hours.

*That square in code is () with rectangular end-sign [ .

Hi @Robert
Download link is not working :sob:

I will re-upload it tomorrow.

1 Like

Hi @Robert

I also have problems to download. Could you help me with this?

Thanks.

1 Like

I cant download it…

1 Like

I am going to recompile it after IDE’s performance issue is fixed.

1 Like

Download error :cry:, please , fixed it.

I need this extension, please share the download link.

1 Like

No the link will not be shared. Look through the topic, the issue has already been reported.

Please consider to make an option to delete folder (not files).

First, as I know Kodular IDE is still not working so I am not able to get my code.
Second you can delete a folder by rm -r “/path/to/folder” command. You may have to use Juan Antonios’ shell extension as Kodular’s does not allow " in input.

1 Like

Will the download be available again - still getting error - same as reported before… Thank you.

Yes right i am also fecing this problem
He have to solve this problem as soon as possible