Skip to main content
Inspiring
October 17, 2022
Question

function getfiles for file and not for folder

  • October 17, 2022
  • 1 reply
  • 777 views

hi, i need to "relink" if files is deplaced OR name is changed

 

this code

		    if (internal_link[k].status == LinkStatus.LINK_MISSING){
			    var folderPath = (Folder.selectDialog(internal_link[k].filePath));
			    var imglist = Folder(folderPath).getFiles(internal_link[k].name+".*");
			    if (imglist.length == 1){
				internal_link[k].relink(imglist[0]);
			    }

 

open à dialog windows only for choose a folder and not select a new file for relink

 

 

thanks for you help

This topic has been closed for replies.

1 reply

Community Expert
October 17, 2022

Change Folder.selectDialog with File.openDialog

This will open a dialog box that will allow you to choose a file. However, I don't see a need for it as your code seems to be doing the right thing. It opens a dialog to select a folder and within that folder it tries to find a file with the name of the linked image and if found it relinks to the found image.

-Manan

Inspiring
October 17, 2022

arf... i tested with file.selectdialog or file.selectdlg....

 

		    if (internal_link[k].status == LinkStatus.LINK_MISSING){
			    var folderPath = (File.openDialog(internal_link[k].filePath));
			    var imglist = Folder(folderPath).getFiles(internal_link[k].name+".*");
			    if (imglist.length == 1){
				internal_link[k].relink(imglist[0]);
			    }
Community Expert
October 17, 2022

As I said why do you want to select a file when what your code expects is indeed a folder to scan it. Secondly what happened when you used the openDialog menthod as you said. Did it work did it not?

-Manan