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

Placing automatic file path

New Here ,
Jun 27, 2019 Jun 27, 2019

Copy link to clipboard

Copied

Does anyone know how to place file path/location (that automatically updates itself when file is moved) in illustrator artboard? My work requires to print large amount of illustrator artworks. So occasionally I have this problem in finding the file path of a printed copy.

TOPICS
Scripting

Views

3.2K

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
Adobe
Community Expert ,
Jun 27, 2019 Jun 27, 2019

Copy link to clipboard

Copied

swaroops89506313  schrieb

(that automatically updates itself when file is moved)

Maybe you can find a script that places the file path into the artwork. But this part won't happen. Only a plugin would be able to do that, but I'm not aware of an  existing one.

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
Adobe Employee ,
Jul 05, 2019 Jul 05, 2019

Copy link to clipboard

Copied

Hi Swaroop,

Moving this discussion to Illustrator Scripting​ community so that you can get some more responses from our scripting experts.

Regards,

Srishti

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
Contributor ,
Jul 08, 2019 Jul 08, 2019

Copy link to clipboard

Copied

I'm not sure if it's doable with a script - you'd propably have to run the script after opening each file, to update it's location.

To update the file on every opening of file, i think it would require a plugin.

Maybe someone else will have an idea.

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
New Here ,
Jul 11, 2019 Jul 11, 2019

Copy link to clipboard

Copied

If anyone could create a plugin for that, our office would be more than willing to pay.

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
Community Expert ,
Jul 12, 2019 Jul 12, 2019

Copy link to clipboard

Copied

swaroops89506313  wrote

If anyone could create a plugin for that, our office would be more than willing to pay.

glad to hear

as others mentioned, there's no way to automatically update file paths using scripting. However, if you open the files via scripting, then you can do anything including updating file paths. So if you're willing to give up Illustrator native way of opening files, including double clicking on files or going to the File menu, then the script below can do what you want.

the script creates a floating window that has a button to open files, always use this button and your file paths will get updated. Just make sure you add a text frame place holder for the path and give it a name in the layers panel "file path"

fileUpdater0.PNG

the script will also add this text frame frame for you if the files don't have it, none of your existing files will have it so, it's a bonus. I place the text frame at the top/left corner of the document, you need to style it and place it in the location of your choice.

so to use, just press the Open... button, select one or more files and the script will open and update the text frame

fileUpdater.PNG

after closing the file, moving it to a different folder and opening again

fileUpdater2.PNG

// script.name = filePathUpdater_swaroops,jsx

// script.description = opens files and updates a text frame with file paths

// script.requirement = a text frame named "file path"

// script.parent = CarlosCanto // 07/12/2019

// script.reference = https://forums.adobe.com/thread/2633801

#target illustrator

#targetengine main

function main () {

    var win = new Window("palette","File Path Updater");

    var btnOk = win.add("button", undefined, "Open...");

    var btnDonate = win.add("button", undefined, "Donate");

    var btnClose = win.add("button", undefined, "Exit");

    win.alignChildren = "fill";

    win.spacing = 8;

    btnOk.onClick = function(){

        var callFunction = openFiles +  '\ropenFiles();';

        btMessaging( 'illustrator', callFunction );

    }

    btnDonate.onClick = function(){

        var callFunction = donate +  '\rdonate();';

        btMessaging( 'illustrator', callFunction );

    }

    btnClose.onClick = function(){

        win.close ();

    }

    win.center();

    win.show();

}

// open files, find "file path" tex frame and update file path. If text frame not found, add it to top/left corner of page

function openFiles() {

    var idoc, filePath, filePathFrame;

   

    var folderStrPref = 'aiscripts.com/filePathUpdater_swaroops/preSelectFolder';

    var preselectFolder = Folder(app.preferences.getStringPreference (folderStrPref));

    if (!preselectFolder.exists) {

        var preselectFolder = new Folder('~/Desktop');

    }

    var sourceFiles = preselectFolder.openDlg('Open Illustrator file...', 'AI: *.ai', true); // select source folder

    if (sourceFiles==null) {   // exit if press cancel in either dialog

        alert('Cancelled by user');

        return;

    } 

    var sourceFolder = sourceFiles[0].parent;

    app.preferences.setStringPreference (folderStrPref, sourceFolder.fsName);

   

    for (var a=0; a<sourceFiles.length; a++) {

        idoc = app.open(sourceFiles);

        filePath = idoc.fullName.fsName;

       

        try {

            filePathFrame = app.activeDocument.textFrames['file path'];

            filePathFrame.contents = filePath;

        }

        catch (e) {

            //$.writeln(e);

            filePathFrame = app.activeDocument.textFrames.add();

            filePathFrame.name = 'file path';

            filePathFrame.contents = filePath;

        }

    }

}

function donate() {

    //alert('entering donate...');

    openURL( 'www.paypal.me/aiscripts' );

   

    function openURL( address ) { 

        var f = File( Folder.desktop + '/aiOpenURL.url' ); 

        f.open( 'w' ); 

        f.write( '[InternetShortcut] URL=http://' + address); 

        f.close(); 

        f.execute(); 

        f.remove();

    };

}

function btMessaging( target, callFunction ) {

    var bt = new BridgeTalk();

    bt.target = target;

    bt.body = callFunction;

   

    bt.onResult = function(result) {

        //alert('onresult: ' + result.body);

    }

    bt.send();

}

main ();

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
New Here ,
Jul 14, 2019 Jul 14, 2019

Copy link to clipboard

Copied

I'm assuming I don't have to include the numbering isn't? Screen Shot 2019-07-15 at 11.02.39 AM.png

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
Community Expert ,
Jul 14, 2019 Jul 14, 2019

Copy link to clipboard

Copied

no you don't, are the numbers being copied when you're copying the script? just select the text copy and paste into your text editor. Line numbers should not get copied.

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
New Here ,
Jul 14, 2019 Jul 14, 2019

Copy link to clipboard

Copied

Ok I loaded it and it works!!.

Thank you very much for the effort.

But the donate button doesn't seem to work. It says the internet shortcut is not valid.

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
Community Expert ,
Jul 15, 2019 Jul 15, 2019

Copy link to clipboard

Copied

glad to hear you got it working. I wonder why the donate button didn't work. Are you on mac? donate link is listed on line 98, www.paypal.me/aiscripts

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
New Here ,
Jul 17, 2019 Jul 17, 2019

Copy link to clipboard

Copied

Unfortunately not many people use PayPal in India. And I certainly can't ask my boss to create account just for this transaction. Is there any other way to make the donation?

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
Enthusiast ,
Jul 17, 2019 Jul 17, 2019

Copy link to clipboard

Copied

You can open file direct and  using this script to get path of target document:

try { 

            var pointTextRef = app.activeDocument.textFrames["TXT-path"]; 

            pointTextRef.contents =  app.activeDocument.fullName.fsName;

    } 

    catch (e) { 

        var pointTextRef = app.activeDocument.textFrames.add();

        pointTextRef.contents = app.activeDocument.fullName.fsName;

        pointTextRef.name="TXT-path";

        pointTextRef.top = 20;

        pointTextRef.left = 10;       

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
New Here ,
Jul 18, 2019 Jul 18, 2019

Copy link to clipboard

Copied

Getting error

Screen Shot 2019-07-18 at 4.34.52 PM.png

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
Enthusiast ,
Jul 18, 2019 Jul 18, 2019

Copy link to clipboard

Copied

You must open a file document before run script.

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
New Here ,
Jul 18, 2019 Jul 18, 2019

Copy link to clipboard

Copied

Oh yeah, it works. Thank you very much.

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
Community Expert ,
Jul 18, 2019 Jul 18, 2019

Copy link to clipboard

Copied

LATEST

no I don't have other money transfer services account, other than bank wire transfer. What do people use in India?

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
Enthusiast ,
Jul 11, 2019 Jul 11, 2019

Copy link to clipboard

Copied

to place a file:

var doc=app.activeDocument;

var oplace=doc.placedItems.add();

var f=new File("C:\\Users\\pc\\Desktop\\f2.ai");

oplace.file=f;

If file f2.ai in folder of target file , it will auto update when move to other file.

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
New Here ,
Jul 11, 2019 Jul 11, 2019

Copy link to clipboard

Copied

Hi daitranthanhoa

Should I save the entire text in .js or only this part-

var doc=app.activeDocument;

var oplace=doc.placedItems.add();

var f=new File("C:\\Users\\pc\\Desktop\\f2.ai");

oplace.file=f;

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
Enthusiast ,
Jul 11, 2019 Jul 11, 2019

Copy link to clipboard

Copied

no, only this part.

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
New Here ,
Jul 12, 2019 Jul 12, 2019

Copy link to clipboard

Copied

Hi daitranthanhoa

I pasted the file in text editor(Mac) and saved it in .js. When I load it from illustrator it shows syntax error.

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
Enthusiast ,
Jul 12, 2019 Jul 12, 2019

Copy link to clipboard

Copied

i think you must change path of file to your file: C:\\Users\\pc\\Desktop\\f2.ai

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
Community Expert ,
Jul 12, 2019 Jul 12, 2019

Copy link to clipboard

Copied

you have to save the script as plain text not rich text, and give it a *.jsx extension

to run scripts

Choose File > Scripts, and choose a script. Alternatively, choose File > Scripts > Other Script, and navigate to a script.

to install scripts

If you place the script in the Adobe Illustrator Scripts folder, the script will appear in the File > Scripts submenu.

If you place the script in another location on the hard disk, you can run the script in Illustrator by choosing File > Scripts > Other Script.

check this thread for the folder location

Installing Scripts in latest Illustrator CC release (V 22.0.1)

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