Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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]);
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Hi i have not test you method yet
For exemple my doc file name contain an error and i modify it
When I need to rethink, I need to select directly the good file and not the folder contain the old name file
Copy link to clipboard
Copied
Is English your native language, if not then probably try to write in your native language and lets see how the translation works. As I said your code expects a folder not a file then it does not matter if you select the correct file or not, it scans the folder. Also, I would suggest you to let one thing work and then move off to things like error handling etc.
-Manan
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@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
Copy link to clipboard
Copied
I second @Manan Joshi on that one. You may need to take a step back, and think about what you are trying to achieve. Also questioning the source material. Scripting is just a handy way of solving issues once they have been clearly established. What about starting all over again with a clear description (no code) of your requirements?
Copy link to clipboard
Copied
the missing link, mean 2 possibility
first file not appear into the file, because removed or cancelled
second name can be changed in this file or present in an other folder with a different name
the function
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]);
}
if (internal_link[k].status == LinkStatus.LINK_MISSING){
var filePath = (File.openDialog(internal_link[k].filePath));
var imglist = File(filePath).getFiles(internal_link[k].name+".*");
if (imglist.length == 1){
internal_link[k].relink(imglist[0]);
}
i have try to modify it by that, but when i inspect the filepath before dlg box and after dlgbox
and filepath is different
one is c:\filepath
second is: desktop:\ filepath
if file is missing, i want just open dlgbox for select the new file for relink (maybe into other file or maybe with different name)
Copy link to clipboard
Copied
hi we have again the probleme on this code
if (nb_link > 0) {
// doc.links.everyItem().update();
// doc.save(); //idem
for (var k = 0; k < nb_link; k++) {
// internal_link = doc.links;
if (k > 0) {
//internal_link[k].update();
}
// On vérifie que le lien est OK :
if (internal_link[k].status == LinkStatus.LINK_MISSING){
var filePath = File.openDialog(internal_link[k].filePath);
alert(internal_link[k].filePath)
internal_link[k].relink(filePath.fsName);
//internal_link[k].reinitLink(filePath.fsName);
}
we have try lot of thing, relink() want file or String,
filePath.fsName is string (filpath is c:/..... and not String), fullname (desktop:/......)
my neighbourg problem come from [é] into my filepath name, but not sur
but impossible to find the solution
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more