JS CS3 Relink image to new path

I've put a script together that resizes images in a doc. What I've been able to do is rename the resized image  and then relink to the renamed images. I'd like to be able to have all the resized images saved into the folder using the doc name which is not hard. What I am finding difficult is setting the path to that folder for the relink.
for example:
var myLinks = app.activeDocument.allGraphics;
var myFpath = myLinks[0].itemLink.filePath
var myFname = myLinks[0].itemLink.name
$.write(myFpath.replace(myFname,app.activeDocument.name+"/"+myFname) +"\r");
returns C:\hold\Untitled-1/file_24791_Scaled.tif
if I try and change +"/"+ to +"\"+ the remaining code is commented out I've also tried "/\/" which returned //
should I try using replace to return /C/hold/Untitled-1/file_24791_Scaled.tif which should work on both PC and Mac?
Any suggestions would be appreciated.
Cheers, John.

Thanks to Kasyan's LinkUsage function I was able to put this script together.
The script is set to look for Tiff and PSD files that are scaled at less then 99%. It will rename the file a version and update the indesign document with that version.
So if you have a doc with Ducky.tif duplicated 3 times in the link panel you will see 3 instances of Ducky.tif. After running the script you will find that in the folder that holds the indd doc a folder named the same as the indd doc is created and within it will be Ducky_3.tif and Ducky_2.tiff. The script will also relink to these new versions of the file.
This script could be changes to allow other types of files but for some reason I've found that if I open a JPG using the PhotoShop script the save dialog opens in Photoshop require user to ok it. I do not seem to get the same issues with Tiff and PSD files. If there is something I'm doing wrong please let me know.
var myDocName = app.activeDocument.name.split(".")[0];
var myDocPath = app.activeDocument.filePath+"/"+app.activeDocument.name.split (".")[0]+"/";
var myLinks = app.activeDocument.allGraphics;
for ( var r = myLinks.length-1; r >= 0; r-- ){ 
    if(myLinks[r].itemLink.parent.absoluteHorizontalScale < 99 && (myLinks[r].itemLink.linkType == 'TIFF' || myLinks[r].itemLink.linkType == 'Photoshop')){
if(LinkUsage(myLinks[r].itemLink)>1){
var verFName = myLinks[r].itemLink.name.split (".")[0];   
var verNum = LinkUsage(myLinks[r].itemLink)
VersionInPS( myLinks[r].itemLink.filePath, myDocPath, verNum);
            if (File.fs == "Windows") {
    var aVerFolder = myDocPath + verFName +"_"+verNum+".tif";
    else if (File.fs == "Macintosh") {
        var aVerFolder = myDocPath  + verFName+"_"+verNum+".tiff";
            myLinks[r].itemLink.relink( File(aVerFolder));
for ( var u = myLinks.length-1; u >= 0; u-- ){ 
    myLinks[u].itemLink.update();
function VersionInPS(myPath, myDocPath, myVersion) { 
   var bt = new BridgeTalk;  
   bt.target = "photoshop";  
   var myScript = 'try {\n';  
   myScript += 'var myPsDoc = app.open(File(\"' + myPath + '\"));\n';  
   myScript += 'var myNewFolder = new Folder("'+myDocPath+'"); \n' ;
   myScript += 'if (myNewFolder.exists){ \n' ;
   myScript += '}else{ \n' ;
   myScript += 'myNewFolder.create(); \n' ;
   myScript += '} \n' ;
   myScript += 'var justname = myPsDoc.name.split (".")[0]; \n' ;
   myScript += 'newFile = new File( myNewFolder+"/"+justname+"_"+'+myVersion+' ); \n' ;
   myScript += 'tiffSaveOptions = new TiffSaveOptions(); \n' ;
   myScript += 'tiffSaveOptions.embedColorProfile = false; \n' ;
   myScript += 'tiffSaveOptions.jepgQuality =10; \n' ;
   myScript += 'tiffSaveOptions.matte = MatteType.NONE; \n' ;
   myScript += 'myPsDoc.saveAs(newFile, tiffSaveOptions, true,Extension.LOWERCASE); \n' ;
   myScript += 'myPsDoc.close(SaveOptions.DONOTSAVECHANGES);\n'; 
   myScript += '}\n';  
   myScript += 'catch (myError) {\n';  
   myScript += 'myPsError += \"myError' + myPath + '\";\n';  
   myScript += '}';  
   bt.body = myScript;
   bt.onResult = function(resObj) {} // empty function - to wait untill PS finishes processing the file
   bt.send(100); // !!! bt.send(1);
function LinkUsage(myLink) {
    var myLinkCounter = 0;
        for (var myCounter =  0; myCounter < myLinks.length; myCounter++) {
        if (myLink.filePath == myLinks[myCounter].itemLink.filePath) {
            myLinkCounter++;
    return myLinkCounter

Similar Messages

  • RELINKING IMAGES MANUALLY IN INDESIGN DOESN'T WORK

    Hello,
    Please help,
    I am opening an Indesign CS3 EPS image file in Indesign CS4 which is made by combining 2 Clipping path images. The problem is: I am not ablt to use the images manually. however, automatic relink works fine. Although I don't know where that option is. I just want to use manual relink.
    any suggestions??
    thanks
    Rachael

    I've seen cases where this "Mini Save"/ "Automatic Recovery" did not work at all.
    Rare cases, but:
    Always when the InDesign file is opened on a different computer and you are working on a network. And someone pulls the plug from that other computer (shutting it down, ignoring the messages that another machine is hooked)!
    SO: I would never rely or bet on the otherwise fabulous feature "Mini Save"/ "Automatic Recovery".
    There is a startup script around in the web by Martin Fischer somewhere on the site hilfdirselbst.ch, that saves a copy of the actual file in a special folder every time you do a "save" or "cmd + s" adding a continous number to the auto saved file name.
    Uwe

  • Lightroom 2.2 can't file files at new path

    I recently changed the path where all my images are located. Do I have to go through each folder one at a time and point them to the location of every folder within the new path? This will take forever.
    For example:
    OLD PATH s:\images\...
    NEW PATH s:\Pictures\...
    Is there no automated way for Lightroom to pick up the new path or a place for me to set it???
    Thanks,
    Jay

    El Deanio wrote:
    My external HDD failed. It had two volumes, one TimeMachine, the second for general use including my ITunes Library. It also had a clone of my old eMac on it.
    it's not a good idea to keep things this way. the data on the data partition is not really backed up. when something happens to the drive just as it did to you you loose everything: TM backups and the data partition. in the future I suggest you keep one drive just for TM and back up everything to it. then you'll have a true backup and won't have to deal with issues as the one you are facing now.
    When the external drive failed I managed to successfully copy the second volume over to a Rescue folder on my iMac's internal HDD with no trouble. All 140gb of it.
    you should have copied it to a separate partition. that would make things easier.
    I now have a new external HDD and I have just tried to MOVE the rescue folder back over to it. However the MOVE fails with the message *'You don't the right privileges for 'System Preferences.app'*. This is but one of the files in the rescue folder and is in a clone of my eMac;s HDD (this computer is currently being repaired by Apple).
    Two questions-
    1) Is is possible to globally override the above (like when Trashing files) so that the move does not fail again; and
    I have located the file 'System Preferences.app' using Finder and have unlocked it and changed its permissions to both read as 'Read/Write". Hopefully this wil stop this.
    this might work. if it doesn't you'll need to do it from terminal.
    However -
    2) The iMac moved about 4.5 gb data back to the external HDD before it got stuck, as the data was being moved, not copied, will this be lost if I delete this 4GB and start again?
    why did you move instead of copy?! this is asking for trouble. check to see if the copied data is still present in the original folder.

  • Mac OSX, 10.7.5, LR 5.6  After creating a new folder in the Destination section and importing images, the new folder name appears as 2010, no matter what name I give it.  Why is it doing this?

    Mac OSX, 10.7.5, LR 5.6  After creating a new folder in the Destination section and importing images, the new folder name appears as 2010, no matter what name I give it.  Why is it doing this?

    I am experiencing Mavericks failing to copy subdirectories from usb sticks, I am backing up game saves from a console. Both sticks I use are fine, same permissions of course since the console wrote the files. Sometimes it copies, sometimes it doesn't. It seems to be related to the mounting process.
    Thank God Apple hasn't (yet) broken bash.

  • When I try to relink images in my inDesign CC Files, in Design becomes unresponsive.

    When I try to relink images in my inDesign CC Files, inDesign becomes unresponsive.

    Have you tried re-booting? Trashing the prefs? See Replace Your Preferences Exporting to .idml? see Remove minor corruption by exporting

  • How do I download my CS3 PhotoShop to my new Apple MacBook Air

    How do I download my CS3 PhotoShop to my new Apple MacBook Air

    Copy the installers to a USB stick, run the install from there.
    Mylenium

  • Clicking "open image in new window" on a jpeg downloads the image

    If I click on "open image in new window" or paste an image address directly in as the url, Safari sometimes downloads that image and sometimes displays the image directly in the browser.
    Why? I'd like to always have it display directly in the browser.
    eg:
    1) this image is displayed in the browser
    http://images.apple.com/home/2008/images/promoleopard20080108.jpg
    2) this image is downloaded
    http://image.wink.com/i/d60210c3_d2lua19wcm9maWxlOmRjODM3YjIxN2E2NDVkMjQ2MDAyYmRjY2JlODIxZGIy_96f96ffffff00.jpg

    Hi,
    At a total guess, the webserver at image.wink.com is incorrectly identifying the images as something other than an image file. If they claim it's a binary file for example, then Safari will treat it like any other file you would normally wish to download.

  • Reference Images in Relative Path

    Captivate 2 allows you to export the background images out
    and then link them in so it is easier to update the images, but the
    paths seem like they have to be absolute only. Is there a way to
    use relative paths instead of the absolute path? I have several
    projects that need to be localized into different languages and
    this is one of the things that is not allowing us to effectively
    use Captivate 2 for the project. Any help would be greatly
    appreciative.

    Hi again Hyp30
    Okay, I have to ask you (and others) for a huge favor here.
    You have hit upon something I strongly feel should be part of the
    next version of Captivate. That typing layer. You are absolutely
    correct that this item cannot be changed. Not only that, but if you
    make a typo, Captivate also records that! Sooo, in my not so humble
    opinion, what would be
    MUCH more useful to us is if the developers created a very
    basic and very simple text animation we could use. Simple typing
    text. Notice all the animations we have. 88 of those puppies I
    think! Why we have fish nibbling characters away, letters flying
    here and there. Yet no simple typing text. If that were available,
    we could forego the typing layer and simply use an animation.
    So, if anyone else feels as strongly about this as I do,
    please submit a request by
    clicking
    here. I suggest this because until the development team hears
    from enough folks, it's not likely to happen.
    Now, for a suggestion. I'm not sure I'd simply reuse the same
    movie for different localizations. If it were me, I'd maybe have a
    project folder where the projects are stored. Then a folder for
    each main project. Then I'd click File > Save As and have
    multiple flavors of each project so I could keep the localizations
    separated.
    Cheers... Rick

  • Display Image from Local path "c:\image.gif"

    Hi Experts,
    Is there anyway to display an image from local path i.e "c:\img.jpg".
    I need to display an image from the path in Dialog(Screen) programming.
    I need to do it using program not any other way...
    Can anyone suggest me a method please.
    Thanks
    Regards
    Naveen

    Hi Naveen,
    You'll have to create a custom control for this and perform coding like this:
    data piccon type ref to cl_gui_custom_container.
    data my_piccon type ref to cl_gui_container.
    data my_pic type ref to cl_gui_picture.
    data my_container type ref to cl_gui_container.
    * invoking the static attribute of the class.
    my_container = cl_gui_container=>default_screen.
    create object piccon
    exporting
    parent = my_piccon
    container_name = 'IMG_CON'
    * STYLE =
    * LIFETIME = lifetime_default
    repid = sy-repid
    dynnr = sy-dynnr
    * NO_AUTODEF_PROGID_DYNNR =
    exceptions
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    create object my_pic
    exporting
    * LIFETIME =
    * SHELLSTYLE =
    parent = piccon
    * NAME =
    exceptions
    error = 1
    others = 2
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    * Can be used to load the picture from the presentation server.
    call method my_pic->load_picture_from_url
    exporting
    url = 'file://D:mydataPicturesMisc_pics 1fw1.jpg'
    * IMPORTING
    * RESULT =
    exceptions
    error = 1
    others = 2
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.

  • Images using absolute path on portlet server not appearing when gatewayed

    I am gatewaying several applications via a Plumtree 5 Portal. Images in these applications when referenced using relative paths (../images/image.jpg) work. Images using absolute path (\applicationFolder\images\image.jpg). When gatewayed they are presented like this:
    http:\\plumtreeServer\portal\server.pt\gateway\PTARGS_0_212_252_0_0_43/https:%3B/remoteServer/applicationFolder/Web/\applicationFolder\images\image.jpg
    Any help would be greatly appreciated.

    I am gatewaying several applications via a Plumtree 5 Portal. Images in these applications when referenced using relative paths (../images/image.jpg) work. Images using absolute path (\applicationFolder\images\image.jpg). When gatewayed they are presented like this:
    http:\\plumtreeServer\portal\server.pt\gateway\PTARGS_0_212_252_0_0_43/https:%3B/remoteServer/applicationFolder/Web/\applicationFolder\images\image.jpg
    Any help would be greatly appreciated.

  • Indesign cs5.5 Applescript - Relink image

    Hi, currently we can relink images from our applescript by using the original image link name but looking to see if we can do if by script label name.  Is this possible.  Thanks, Joe

    You can't use a script label to perform a relink, but is that what you're really asking? Or are you trying to use the script label to identify the linked item you want to relink?
    Dave

  • I want to transfer my Adobe CS3 licence to my new Laptop. Please help me for Deactivate Adobe CS3 licence from old Laptop

    I want to transfer my Adobe CS3 licence to my new Laptop.
    Please help me for Deactivate Adobe CS3 licence from old Laptop

    Hi sanket chalke,
    I'm not sure what Adobe product you need help with, but you might want to start with this document, which has deactivation information: Activation & Deactivation Help
    Please let us know how it goes.
    Best,
    Sara

  • Placing images on a path

    i have multiple images i want to place on a cruved path. how can i go about doing this?
    cheers,

    I would draw the path and then turn on Smart Guides (CMD+U) to snap a particular point on the images along the path. See my attached screenshot. I did this with rectangles, but you could also use placed images. Then just delete the curved line when you are done using it for placement.
    -JM

  • I have used Illustrator CS3 on my two try or three previous computers. Now I try to install Illustrator CS3 on a my new (4 weeks old) computer. Adobe does not allow me, but demands me to proof myself being an owner of Illustrator CS2 or older. I don't man

    I have used Illustrator CS3 on my two try or three previous computers. Now I try to install Illustrator CS3 on a my new (4 weeks old) computer. Adobe does not allow me, but demands me to proof myself being an owner of Illustrator CS2 or older. I don't manage to speak English on phone, bad hearing, to fast spoken, odd expressions.What can I do? Is there a possibility to write a complain?

    You can use online chat to talk with Adobe.  For the link below click the Still Need Help? option in the blue area at the bottom and choose the chat option...
    Serial number and activation chat support (non-CC)
    http://helpx.adobe.com/x-productkb/global/service1.html ( http://adobe.ly/1aYjbSC )

  • Move undo and temporary tablespace to new path

    Hi All,
    I want to move my undo and temporary tablespace to new path because of space issue. I am using Oracle 10g release 2 and working on production server can't take shutdown without prior permission.
    Please tell me the steps to do so...
    thanks
    Api

    About create/change/drop
    UNDO:
    SQL>show parameter undo
    NAME TYPE VALUE
    undo_management string AUTO
    undo_retention integer 900
    undo_tablespace string UNDOTBS1
    SQL> CREATE UNDO TABLESPACE undotbs2 DATAFILE '+DATA_NEWPATH' SIZE 100M AUTOEXTEND ON;
    http://www.oracle-base.com/articles/9i/AutomaticUndoManagement.php
    SQL> alter system set undo_tablespace=undotbs2;
    *** after that can drop UNDOTBS1
    TEMP:
    SQL> CREATE TEMPORARY TABLESPACE TEMP TEMPFILE '+DATA_NEWPATH' SIZE 500M AUTOEXTEND ON NEXT 100M MAXSIZE unlimited EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;
    http://www.idevelopment.info/data/Oracle/DBA_tips/Tablespaces/TBS_3.shtml
    SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2;
    *** after that can drop old temp tablespace -> DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES

Maybe you are looking for

  • Error in Configuring the EBS Adapter for WebCenter

    Hi All, when I'm configuring EBS Adapter for Web Center I'm getting the below Error while running the sql script AXF_EBS_SOLUTION_DATA.sql ,and I check the AXF_CONFIGS table is not available in db schema, not sure when this table will create. please

  • Leopard, can it run without core image?

    well i got an ibook g4 from my friend and i bought leopard disk new from ebay it was boxed and all well anyways i want to install leopard on my ibook which is running 10.4.11 the specs are 1.7 ghz 786 ram 60 gb hard drive my question is that i think

  • Tablespace in oracle 8.1.6

    we had an oracle server running in linux machine.im maintaining 4 databases on it. we dont create tablespaces for each of them. so the default tablespace of all my schema is using the tablespace 'system'. i reconfigure by creating users for default t

  • Assign song to multiple albums?

    Is there a way to assign a song to multiple albums? For instance, if I want a track to show in Greatest Hits and also the real album it's from, I need to have the song loaded twice; once for each album. Is there a way around this? I know some people

  • Prompt when processing a dimension

    Hi, When i am processing the account dimension i am getting a prompt Stating the the file name already exists in the location do i want to replace it. This only comes up on one machine is there a way to stop this prompt from coming up. Many thanks