Copy link to clipboard
Copied
Each of the selected files should open.
Opening files is very important.
Only the path of the folder should be displayed in the browser,
the path of each selected file should not be displayed in the browser.
var selectFolder = Folder.selectDialog();Folder Select Dialog Shouldn't be
There should be a Selected Files
var dialog = new Window('dialog', 'Select Files');
dialog.orientation = 'column';
var fileGroup = dialog.add('group');
fileGroup.orientation = 'row';
fileGroup.alignment = 'left';
var filePath = fileGroup.add('edittext', undefined, '');
filePath.preferredSize.width = 300;
var browseButton = fileGroup.add('button', undefined, 'Browse');
browseButton.onClick = function () {
var folderToOpen = Folder(filePath.text);
var selectedFiles = folderToOpen.openDlg('Select JPG files', '*.jpg', true);
if (selectedFiles) {
var selectedFolders = [];
var selectedFilesPaths = [];
for (var i = 0; i < selectedFiles.length; i++) {
var folderPath = decodeURI(selectedFiles[i].parent.fsName);
selectedFilesPaths.push(decodeURI(selectedFiles[i].fsName));
var found = false;
for (var j = 0; j < selectedFolders.length; j++) {
if (selectedFolders[j] === folderPath) {
found = true;
break;
}
}
if (!found) {
selectedFolders.push(folderPath);
}
}
filePath.text = selectedFolders.join('\n');
filePath.text = selectedFilesPaths.join('\n');
} else {
//alert('No file selected or invalid file.');
return;
}
};
var buttonGroup = dialog.add('group');
buttonGroup.alignment = 'right';
var okButton = buttonGroup.add('button', undefined, 'OK');
okButton.onClick = function () {
dialog.close();
var selectedFiles = filePath.text.split('\n');
for (var i = 0; i < selectedFiles.length; i++) {
openFile(selectedFiles[i]);
}
};
var cancelButton = buttonGroup.add('button', undefined, 'Cancel');
cancelButton.onClick = function () {
dialog.close();
};
var dropdownList = dialog.add('dropdownlist');
dropdownList.preferredSize.width = 200;
var addPathButton = dialog.add('button', undefined, 'Add to Dropdown');
addPathButton.onClick = function () {
var newPath = filePath.text;
saveFolderPath(newPath);
storedPaths.push(newPath);
dropdownList.add('item', newPath);
};
var removePathButton = dialog.add('button', undefined, 'Remove from Dropdown');
removePathButton.onClick = function () {
if (dropdownList.selection !== null) {
var selectedIndex = dropdownList.selection.index;
var selectedPath = storedPaths[selectedIndex];
storedPaths.splice(selectedIndex, 1);
dropdownList.remove(selectedIndex);
var filePath = "C:/Code/input.txt";
var file = new File(filePath);
file.open("r");
var lines = file.read().split("\n");
file.close();
file.open("w");
for (var i = 0; i < lines.length; i++) {
if (lines[i] !== selectedPath) {
file.writeln(lines[i]);
}
}
file.close();
}
};
function openFile(file) {
app.open(new File(file));
}
function saveFolderPath(path) {
var file = new File('C:/code/input.txt');
file.open("a");
file.writeln(path);
file.close();
}
var storedPaths = [];
var filePathValue = "C:/Code/input.txt";
var file = new File(filePathValue);
if (file.exists) {
file.open("r");
while (!file.eof) {
var line = file.readln();
storedPaths.push(line);
dropdownList.add('item', line);
}
file.close();
}
dropdownList.onChange = function () {
filePath.text = storedPaths[dropdownList.selection.index];
};
dialog.show();
So you selected multiple files but do not want them to be displayed?
So just change your script. You wrote this, correct?
Yes.I have selected multiple files but I want only the path of the folder to be displayed.Not the total of the selected files.
Have you tried commenting out that line?
You can delete the line in a text editor or comment it out by adding two slashes at the beginning of the line (»//«).
Copy link to clipboard
Copied
So you selected multiple files but do not want them to be displayed?
Copy link to clipboard
Copied
Yes.I have selected multiple files but I want only the path of the folder to be displayed.Not the total of the selected files.
Copy link to clipboard
Copied
Then why did you include the line
filePath.text = selectedFilesPaths.join('\n');
?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This is a problem with grabbing a script from someone else and then coming here to have it fixed. Why not just go back to your friend?
Copy link to clipboard
Copied
Have you tried commenting out that line?
Copy link to clipboard
Copied
I don't know how to make a script and my friend also doesn't know how to make a script
Copy link to clipboard
Copied
You can delete the line in a text editor or comment it out by adding two slashes at the beginning of the line (»//«).
Copy link to clipboard
Copied
So just change your script. You wrote this, correct?