r/Python • u/Technical-Ad-565 • 4d ago
Discussion Coding to comparing filenames and foldernames on android
UPDATE: I have temporary solved my immediate problem with using the find and diff commands from Termux.
This got me a usable list of differences. Although I had to move folders around a bit.
In the long run I will use Python for this and further functions.
END UPDATE.
I need to make a program för comparing file names and subfolder names between 2 folders containing something like 100000 files and subfolders. And it's around 650GB of data on the phone.
(Background: I have programmed professionally since 1979, but not on android or pc. Are totally new to Python. I use the phone almost always, very rarely the pc, even for my own business.)
I have searched for and tried extensively with apps for android but there isn't any useful. Apparently mainly due to permission problems.
The main question is: is it at all possible due to the permission problem?
(The solution by transferring the files to the pc have the problem that it takes very long time. And I really want a way to do it relatively often.)
The second question is: are the any existing code (snippets) for this or have you some advices in general?
Thanks on advance for any suggestions.
//Thomas
2
u/11krish11 2d ago
Yes, it is definitely possible directly on Android using Termux (a Linux terminal environment app available on F-Droid or GitHub).
termux-setup-storageand allow "All files access" in Android Settings so scripts can scan your internal storage/SD card without permission blocks.setstructures usingos.scandir()oros.walk(), then use set operations:Fast Comparison: Computing
folder_a - folder_busing sets is an $O(n)$ in-memory operation that completes in seconds once the path tree is indexed.