FileTools : Some tools to work with files

1.Introduction

Description: The name of extension is FileTools and features are similar to its name.
It provides tools to work with Files and Folders.

Latest Version: 10.1
Last Updated: 2021-10-08T18:30:00Z

2.Blocks

image

image

image

image

image

image

3.Documentation

component_method

Returns path to application specific directory
Thanks to @bodymindpower for suggesting changes

image

Returns a list of available storage directories.

blocks%20(18)

Copies file from source to destination folder.

blocks

Copies file from source to destination asynchronously.Use this to copy big files to avoid runtime errors.

component_method%20(2)

Creates Application Specific Directory in case it does not exists

blocks (1)

Creates a single directory.It triggers ‘Directory Created’ with boolean true or false

image

Deletes given file or folder.If it is directory then all subdirectories will be deleted and this can take some time.It triggers ‘FileDeleted’ event with boolean true or false.

blocks%20(21)
blocks%20(22)

Returns true if file or folder exists else false

blocks

Returns files list from given directory (if it exists) .Use file extension as filter like mp3,txt,etc.If you don’t want to use filter then use empty string.Also if don’t want to get subdirectories then set ‘withFolders’ to false else true.If recursive is set to true then it will also get files from subdirectories recursively.

blocks (1)

Works same as FilesList but it gets file list asynchronously which denies any oppertunity of runtime error in getting files list from a directory having so much files.It raises ‘GotFileList’ event with files list.

image

Returns file list from assets

blocks (4)

Returns file name from path if it exists

blocks (5)

Returns current size of file or folder

blocks (6)

Returns file path from file name.In this case it will return /storage/sdcard/mFile.txt

blocks (7)

Returns folders list of given directory

blocks (6)

Returns free size of directory in bytes.
Note: it uses absolute file Path

blocks (16)

Converts file path to content uri

blocks (18)

Moves file from source to destination asynchronously.

blocks%20(26)

Checks that given path is complete path or not
For example: /testt.txt and /mnt/sdcard/Android/com.sunny.notez/files/testt.txt are not same.

blocks (15)

Returns that folder/file is executable or not

blocks (14)

Returns true if path is file else false

blocks (13)

Returns true if file/folder is hidden else false

blocks (11)

Returns true if file/folder is readable else false

blocks (12)

Returns true if file/folder is writable else false

blocks%20(46)

Last modified time of file/folder in given format

blocks%20(47)

Mime type of given file.In above case it will return text/plain

blocks%20(48)

Moves file from source to destination and deletes source file

blocks%20(49)

Converts content uri to file path

blocks (10)

Renames file without deleting it

blocks (7)

Returns total space of directory
Note: it uses absolute file Path

4.Downloads

Aix
Here are two download links for Aix and Aia:
Download link 1:
com.sunny.FileTools.aix (31.8 KB)

Download link 2: com.sunny.FileTools.aix - Google Drive

Aia
Download Link1: FileTools.aia (51.7 KB)
Download Link2: FileTools.aia - Google Drive

AIA does not have latest version of extension

5.Credits

It was not only me who was included in making this extension.
A lot of people helped me to make this extension.
I want to say thank you @Deepanshu_Arya and @hammerhai for helping me in making FileTools:heart_eyes:
Also I am very thankful to App Inventor as AI source files helped me very much in adding new methods :smiling_face_with_three_hearts:
StackOverFlow also helped me a lot in making FileTools
And a lot of thanks to @KodularCreator for this awesome platform:heart:
Honorable mention:
@bodymindpower for reporting some bugs and changes

6.Updates/Bug Fixes

ChangeLog Version2

New blocks
Added two new blocks

Bug Fixes

  • All methods returning files list will now return empty list(if files list is empty) instead of runtime error
  • Mime Type method will return mime type with more accuracy.
  • Fixed some null pointer exceptions
ChangeLog Version3

New blocks

Added three new blocks

component_method%20(5)

component_method%20(6)

component_method%20(4)

Changes
New version includes changes in some blocks

  • ‘Application Specific Directory’ now returns path to ASD
  • Replaced ‘File’ with ‘FileSystems’ in ‘Available Storage Directory’ block but I am not sure it is working or not

Bug Fixes

  • Some changes in ‘Available Storage Directory’ block
ChangeLog Version4

New blocks
Added 6 new blocks:

image

image

image

image

image

image
Changes

  • Replaced path with name.Now it will find path from file name (Thanks to App Inventor)
  • Some other minor changes

Bug Fixes

  • Now it is able to copy files from assets (Thanks @bodymindpower)
  • ‘AvailableStorageDirectories’ blocks is working now (Thanks @salem_m_s2021)
ChangeLog Version5

Changes

  • Added ‘recursive’ in FilesList and FileListAsync

image

image

Bug Fixes

  • Fixed bug in Delete method
  • Fixed bug in getting assets list using FilesList.Use // in FilesList as dir to get Assets list while using Companion
  • Some minor bug fixes
ChangeLog Version6

Changes

  • Removed some un-neccessary methods and imports which reduced aix size (40 kb to 31kb) :sweat_smile:
  • Some internal changes like using empty string in any path socket will also return an empty string
  • Fixed several spelling and grammar mistakes
ChangeLog Version7

Bug Fixes

  • Fixed bug in FileListFromAssets method

ChangeLog Version8

Bug Fixes

Changes

  • Some internal changes and fixed spelling and grammar mistakes
ChangeLog Version9

Bug Fixes

  • Fixed bug in CopyFile and CopyFileAsync methods which were not copying file from assets
  • Fixed bug in IsFile method which was returning false for every asset’s file

Changes

  • Some internal changes
  • Removed some un-necessary libraries
ChangeLog Version10

Changes

  • Extension will not work in Kodular Companion for asset files
    For example, //foto.png will refer to /storage/emulated/0/AppInventor/assets/foto.png (Android < 10)
  • FileList and FileListAsync now have multi filter support (separated by ,)
  • Some internal changes

Bug Fixes

  • PathFromUri is now compatible with Android >= 10
ChangeLog Version10.1
  • Fixed bug in IsFile method which was not working for Asset files.
    It was affecting copy and move operations.
64 Likes
How to download files from Google drive using download component?
How to make folder lock app?
Set condition to Component download + extension App PDF Viewer
How to delete folder from storage?
How to get file name where the text is inserted?
Pick and play audio from sd card
File component and media files
Image viewer app
How to create local video list in Dynamic Card View
Help to create file path
Help to create file path
Error 601: No Corresponding Activity Found in PDF App
How to run Media Scanner after copying file
A problem in the file name with path
How to rename a file,s format
How to get file list from a specific folder
Problem with Taifun File Tools
2020: The Year in Review
How to upload file in Custom Webview
Get all files in any folder
How do I show a picture in the internal storage in the app?
How to create multiple/dynamic markers on google maps
The operation Picture cannot accept the arguments: , [*nothing*]
Download file in specific folder
How to fix error 701 (solution)
Can you run lottie from file loaded?
Can you run lottie from file loaded?
Can you run lottie from file loaded?
How can i set size limit upload file on cloud
Save canvas on specific folder
How To Show Gallery Video in App?
Native Image picker & Activity Starter picker problem
Delete a file from the downloads
Another way to upload images to google drive
Image uploading not working on homework site app
Attempt to get length of null array error message
Webview file upload not working
Unknown error after building apk, attempt to get length of null array
Create new directory
How to get video path with Activity starter?
Unknown error after building apk, attempt to get length of null array
How to effectively translate your app
How to import csv file into tinydb?
Getting a file path from a content URI?
Problem in file uploading after picking up file
Assets image list
Assets image list
How to save webpages and images using tinyDB?
How put random images
QR Scanner - New APP!

And here is a question:

Should I give Aia file?

  • Yes
  • No
  • Can’t say

0 voters

9 Likes

Nice Work Bro, Keep it up, :heart_eyes:

2 Likes

Thank you:heart_eyes:

4 Likes

As far I know these volume/drive letters are only used on Windows. :sweat_smile:

And, what happens if we retrieve a list of files and folders? You know, it takes a while to list them. (I didn’t tested yet by the way) So I hope it is not stopping the app activity while this block finishes its job. :slightly_smiling_face:

2 Likes

I think you should remove my mention, I didn’t really help you because I didn’t get to your PM in time before you got a fix from someone else :sweat_smile:

1 Like

Great job soon I will try it

Actually when I run code in Intellij IDEA it returned those names so I copy-pasted them here :sweat_smile:

2 Likes

For me it does not matters that you got my PM or not but you encouraged me to find solution myself.

Fun Fact(s)

1.The blocks Application Specific Directory was the block I asked to @hammerhai for help.
2. Then I asked @Deepanshu_Arya for help and he gave me this method.

public String getPackageName()

But I found it hard to implement.
3.So I searched on Google and StackOverFlow and got some not working solutions.
4.I don’t know why I opened AppyBuilder Code Editor and got a public extension related to Version Name and Version Code.
I got my solution after some unsuccessful ‘modifications’

Those two blocks took half time of FileTools’ other blocks.

3 Likes

I don’t think my name’s should be there as the really things which helped you are:


Keep developing :+1:

21 Likes

Yes…you are right :heart_eyes:
StackOverFlow helped me a lot…

6 Likes

ChangeLog Version 2

New blocks
Added two new blocks

Bug Fixes

  • All methods returning files list will now return empty list(if files list is empty) instead of runtime error
  • Mime Type method will return mime type with more accuracy.
  • Fixed some null pointer exceptions
4 Likes

Have you used FileTools?

  • Yes
  • No

0 voters

What is your experience using FileTools?

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

0 voters

2 Likes

Yes, I just took a quick look and I noticed a few things compared to Taifun’s File extension:

  • FileTools.ApplicationSpecificDirectory does not give the full path like Taifun’s File extension, but (true / false). However, to access files in this folder, the full path (Companion / APK) is required. Please change / add this.

  • FileTools.AvailableStorageDirectories does not show any directory (Taifun does it)

I’ll take a closer look at the extension later …
Good work! :+1:

2 Likes

Actually application specific directory returns true if ASD exists else false.
And thanks for bug report.
I will try to solve the problem as soon as possible.
Thank you.

1 Like

Yes, I know, but we need also the path to access files in this folder. So please add this.

1 Like

:+1:
Will be added.

2 Likes

ChangeLog Version3

New blocks

Added three new blocks

component_method%20(5)

component_method%20(6)

component_method%20(4)

Changes
New version includes changes in some blocks

  • ‘Application Specific Directory’ now returns path to ASD
  • Replaced ‘File’ with ‘FileSystems’ in ‘Available Storage Directory’ block but I am not sure it is working or not

Bug Fixes

  • Some changes in ‘Available Storage Directory’ block
1 Like

java.lang.NoClassDefFoundError: Failed resolution of: Ljava/nio/file/FileSystems;
Note: You will not see another error reported for 5 seconds.

1 Like

Thanks :hugs:

2 Likes