How to get filename from path

My App picks a picture previously stored in my smartphone.
Then it uploads the image via FTP. It works OK.
But I need to add to the filename the customer ID=“12345” like: “12345_20220305_070741.jpg” (20220305_070741.jpg been the name of the image as it is saved by the smartphone camera software).
I need a reliable way to do this as if I hard code some trick it may crash in the future as a result of some Android or camera software update.


In one specific case I have:
path: \storage\emulated\0\DCIM\Camera\20220305_070741.jpg
I need to change the filename from 20220305_070741.jpg to 12345_20220305_070741.jpg
But I need to have this “12345_20220305_070741.jpg” loaded into a variable that will be stored with the purpose of composing the URL of this image once it is loaded via FTP into a web directory.
Only changing the filename without been able to get the filename separated from the path is not what I need.
And the user will not know the filename as he will only select an image from the gallery.

I never used this block, but I’m pretty sure that an absolute path is required.
So there shouldn’t be any problem using this method.

Maybe try like this

1 Like

Hi, may be I am not understanding your explanation.
I want to change the file name but I don’t have the name of the file the user selected.
All I have is “\storage\emulated\0\DCIM\Camera\20220305_070741.jpg”
I need this “20220305_070741.jpg”
I know of ways to do this but I am afraid Android or the camera software may change and “\storage\emulated\0\DCIM\Camera” may change in the future and render the app unusable.
So I am looking for an automated way to extract the file name only from the path.
May be there is another way that will be reliable enough on the long term.

I was able to extract the filename with the global filename block above. Thanks

1 Like

And how much does that help? To rename the file and upload this renamed file, you need to do something like this:


Here is a test APK (which renames the image, but does not upload the image):
pickRename.apk (5.5 MB)


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.