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

Get the missing links from server

Guide ,
Dec 22, 2016 Dec 22, 2016

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

Screen Shot 2016-12-22 at 4.54.20 PM.png

Step 2: Choose the main folder (for now i used Test_Images) to search the image. We need to search in the subfolders too

Screen Shot 2016-12-22 at 4.55.43 PM.png

Step 3: Copy the found image to Recovered Missing Link folder (created a folder where active document )

Screen Shot 2016-12-22 at 4.55.31 PM.png

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

TOPICS
Scripting

Views

860

Translate

Translate

Report

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 1 Correct answer

Mentor , Dec 23, 2016 Dec 23, 2016

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

...

Votes

Translate

Translate
Guide ,
Dec 22, 2016 Dec 22, 2016

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

Votes

Translate

Translate

Report

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
Mentor ,
Dec 23, 2016 Dec 23, 2016

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

Votes

Translate

Translate

Report

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
Guide ,
Dec 23, 2016 Dec 23, 2016

Copy link to clipboard

Copied

LATEST

Hi Jarek,

Working superbly. Thank you so much.

Have a great weekend.

Thanks,

K

Votes

Translate

Translate

Report

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