Skip to main content
Inspiring
October 17, 2022
Question

function getfiles for file and not for folder

  • October 17, 2022
  • 1 reply
  • 785 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

-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

folderpath is different to internallink.filepath


@laurence roussel12011930 the problem is that you don't pay attention to what the other is saying. You asked to let you select a file using the dialog box. I gave you the function openDialog, using this you are selecting a file, and then you are trying to find files within a file. The line which is giving you an error means in your case to find files with a file(the one you selected from the dialog), does this make sense to you, no right?

So problem is not the code but the logic that you are trying to make. To me the simple logic would be your initial code, select the folder and search it for the file, if the file is found relink to it and you are done.

-Manan

-Manan