Copy link to clipboard
Copied
Hi,
I need to find the missing links in the server if anything present with the same image name.
Step 1: Get the missing link name
Step 2: Choose the main folder (for now i used Test_Images) to search the image. We need to search in the subfolders too
Step 3: Copy the found image to Recovered Missing Link folder (created a folder where active document )
I got some help useful threads in the forum (Re: need to relink missing links to files with extensions ). Thank you [Jongware] .But those are useful to link the images. I need to collect the images and copy in a particular folder.
The below coding not copy the images.
var i, j, searchfolder, movefolder=[];
for (j=0; j<app.documents.length; j++) {
doc = app.documents
;
imgs = doc.links;
path = doc.filePath;
searchfolder = searchfolder || new Folder(path);
searchfolder = searchfolder.selectDlg(
"Find a path to "+doc.name+"'s images. Should contain "+
imgs[0].name+".*");
for (i=0; i<imgs.length; i++)
{
if (imgs.status == LinkStatus.LINK_MISSING)
{
imglist = findAnyFileDownThere(imgs.name, searchfolder);
if (imglist.length == 1)
{
movefolder.push( Folder(path + "/Recovered Missing Link/").getFiles() );
}
}
}
}
function findAnyFileDownThere (filename, path)
{
var result, folderList, fl;
result = Folder(path).getFiles (filename+".*");
if (result.length > 0)
return result;
folderList = Folder(path).getFiles(function(item) { return item instanceof Folder && !item.hidden; });
for (fl=0; fl<folderList.length; fl++)
{
result = findAnyFileDownThere (filename, path+"/"+folderList[fl].name);
if (result.length > 0)
return result;
}
return [];
}
Please help to solve this.
Advance thanks,
K
Hi,
Hm..., to copy I suggest to use method File.copy()
...and to relink - method Link.relink()
...var
i, j,
doc, imgs, path, cName, cFile,
imglist, searchfolder, movefolder;
for (j=0; j<app.documents.length; j++) {
doc = app.documents
; imgs = doc.links;
path = doc.filePath;
searchfolder = searchfolder || new Folder(path);
searchfolder = searchfolder.selectDlg(
"Find a path to "+doc.name+"'s images. Should contain "+
imgs[0].name+".*");
for (i
Copy link to clipboard
Copied
Hi All,
I hope everyone is in holiday mood. Any suggestion helpful to complete my task
Happy Christmas and New year wishes to all
Copy link to clipboard
Copied
Hi,
Hm..., to copy I suggest to use method File.copy()
...and to relink - method Link.relink()
var
i, j,
doc, imgs, path, cName, cFile,
imglist, searchfolder, movefolder;
for (j=0; j<app.documents.length; j++) {
doc = app.documents
; imgs = doc.links;
path = doc.filePath;
searchfolder = searchfolder || new Folder(path);
searchfolder = searchfolder.selectDlg(
"Find a path to "+doc.name+"'s images. Should contain "+
imgs[0].name+".*");
for (i=0; i<imgs.length; i++)
{
if (imgs.status == LinkStatus.LINK_MISSING)
{
cName = imgs.name;
imglist = findAnyFileDownThere(cName, searchfolder);
if (imglist.length == 1)
{
movefolder = Folder(path + "/Recovered Missing Link");
if (!movefolder.exists) movefolder.create();
cName = imglist[0].name;
cFile = File(movefolder + "/"+ cName);
if (!cFile.exists) imglist[0].copy(cFile);
imgs.relink(cFile);
}
}
}
}
function findAnyFileDownThere (filename, path)
{
var result, folderList, fl;
result = Folder(path).getFiles (filename);
if (result.length > 0)
return result;
folderList = Folder(path).getFiles(function(item) { return item instanceof Folder && !item.hidden; });
for (fl=0; fl<folderList.length; fl++)
{
result = findAnyFileDownThere (filename, path+"/"+folderList[fl].name);
if (result.length > 0)
return result;
}
return [];
}
Keeping Best Wishes for all these days
Jarek
Copy link to clipboard
Copied
Hi Jarek,
Working superbly. Thank you so much.
Have a great weekend.
Thanks,
K