Skip to content
Advertisement

How to create a list of images and their names in a folder

I am using the following code to create a list of image files with tif extension. The current result of the code is a list with the address of the .tif files.

JavaScript

result:

JavaScript

How can I revise the code to create two lists a) name of the file with .tif b) name of the file. here is the example:

JavaScript

edit to the code from solutions:

JavaScript

result:

JavaScript

Advertisement

Answer

For the first list you want you can just use the function split(“”) on each one of the term of your list and use the last element of the list created by split. And for the second one you can just take the first list you’ve created and split on “.”, you will just have to save the first element of the list.

JavaScript

But you can also try to not include the path in rather_list like that:

JavaScript

You can merge the two to have this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement