Get file name from session tokken

HI Everyone
I m trying to make a UXP for photoshop in which at the beginning i am taking taking images from user. i instantly converted them to tokens and saved in an array, now at the later stages of my plugin i want to loop through those images and get the name of all images.
The problem is that now the array contain the session tokens , hwo i should get the name without opening each image.

const fileTypes = [“jpg”, “jpeg”, “png”];
const options = {
types: fileTypes,
canSelectMultiple: true
const pickedFiles = await fs.getFileForOpening(options);
if (pickedFiles) {
pickedFiles.forEach(pImg => {


// and in addition to that can any expert guide me how to handle the flow next time for a structure like that


When you push to the array why not push an object that includes the filename and the token as properties?


a token is a string and not an object, so as it is you can’t get anything from it.
your options are:

  1. convert it back to entry when needed and get name from entry (not recommended)
myEntry = await fs.getEntryForPersistentToken(myToken)
fileName =

  1. get and store file path and/or name from entry while converting it to a token

I’d store my tokens as an array of objects

let fileTypes = ["jpg", "jpeg", "png"];
let options = {
    types: fileTypes,
    allowMultiple: true //not canSelectMultiple
let myFiles = await fs.getFileForOpening(options);

if (myFiles){
    let myTokens = => {
        return {
        path: myEntry.nativePath,
        token: fs.createSessionToken(myEntry)

now the array called myTokens will contain a list of objects

      name: "file1.jpg",
      path: "D:\myFolder\file1.jpg",
      token: "session-token/xxxxxxxxxxx"
      name: "file2.jpg",
      path: "D:\myFolder\file2.jpg",
      token: "session-token/xxxxxxxxxxx"

to loop through it:

myTokens.forEach(myToken => {

you can also store just the path of the file and get name like this:

let fileName = path.basename(myToken.path)
1 Like

because i am too weak in programming, :sweat_smile:
got the solution now. Thankyou