Copy link to clipboard
Copied
The Bridge alert dialog displays the folder name KGD with the file path.
How can I remove the file path and keep the KGD folder name?
button1.onClick = function() {
var folderName = Folder.selectDialog("");
alert('alert 1: '+folderName);
}
You can find the index of the last "/" in folderName then get the substring after that
var folderName = Folder.selectDialog("");
var lastFolderIndex = folderName.toString().lastIndexOf("/");
var lastFolder = folderName.toString().substr(lastFolderIndex+1);
alert('alert 1: '+lastFolder);
You can split folderName into an array based on "/" then get the last array item
var folderName = Folder.selectDialog("");
var folderNameToArray = folderName.toString().split("/");
var lastFolder = folderName
...
Copy link to clipboard
Copied
You can find the index of the last "/" in folderName then get the substring after that
var folderName = Folder.selectDialog("");
var lastFolderIndex = folderName.toString().lastIndexOf("/");
var lastFolder = folderName.toString().substr(lastFolderIndex+1);
alert('alert 1: '+lastFolder);
You can split folderName into an array based on "/" then get the last array item
var folderName = Folder.selectDialog("");
var folderNameToArray = folderName.toString().split("/");
var lastFolder = folderNameToArray[folderNameToArray.length-1];
alert('alert 1: '+lastFolder);
Copy link to clipboard
Copied
This might be the simplest method (only tested on Windows)
var folderName = Folder.selectDialog("");
alert('alert 1: '+folderName.name);
alert('alert 2: 'folderName.displayName); // displays spaces instead of %20
Copy link to clipboard
Copied
Many thanks for the explanation. The first two code samples work great.
The third code is simple and elegant but throws an error in the mac system.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now