Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
5

Add only the folder paths of the files to be selected in the browser. Folder paths and not the names

Explorer ,
Nov 05, 2023 Nov 05, 2023

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 FilesDate_5.11.2023. 16;2 = 5=.jpg

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();

TOPICS
Windows
510
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 5 Correct answers

Community Expert , Nov 22, 2023 Nov 22, 2023

So you selected multiple files but do not want them to be displayed? 

Translate
LEGEND , Nov 22, 2023 Nov 22, 2023

So just change your script. You wrote this, correct?

Translate
Explorer , Nov 24, 2023 Nov 24, 2023

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.

Translate
Community Expert , Dec 04, 2023 Dec 04, 2023

Have you tried commenting out that line? 

Translate
Community Expert , Dec 10, 2023 Dec 10, 2023

You can delete the line in a text editor or comment it out by adding two slashes at the beginning of the line (»//«). 

Translate
Adobe
Community Expert ,
Nov 22, 2023 Nov 22, 2023

So you selected multiple files but do not want them to be displayed? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 24, 2023 Nov 24, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 26, 2023 Nov 26, 2023

Then why did you include the line 

filePath.text = selectedFilesPaths.join('\n');

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 03, 2023 Dec 03, 2023
I don't know about that line. Got this script from a friend.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 04, 2023 Dec 04, 2023

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2023 Dec 04, 2023

Have you tried commenting out that line? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 10, 2023 Dec 10, 2023

I don't know how to make a script and my friend also doesn't know how to make a script

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 10, 2023 Dec 10, 2023
LATEST

You can delete the line in a text editor or comment it out by adding two slashes at the beginning of the line (»//«). 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 22, 2023 Nov 22, 2023

So just change your script. You wrote this, correct?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines