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

Stuck with File Path

New Here ,
Apr 29, 2009 Apr 29, 2009

Copy link to clipboard

Copied

I am writing a very simple script that exports an image's cutline for my newsroom, i am getting stuck with the having it write the file to the correct path. When I run script as below it works, writing the file to my documents:

function writeCutline () {
                // Linefeed shizzle
            if ($.os.search(/windows/i) != -1)
                fileLineFeed = "windows";
            else
                fileLineFeed = "macintosh";
        
    var fileName = app.activeDocument.name

    var MetaInfo = app.activeDocument.info;
    MetaInfo = MetaInfo.caption;
    var fileOut = new File(Folder.myDocuments + '/'+ fileName.substring(0,fileName.length-4)+ '.txt');
    fileOut.linefeed = fileLineFeed;
    fileOut.open("w", "TEXT", "????");
    fileOut.writeln(MetaInfo);
    fileOut.close();
}
writeCutline();

What I want it to do is:

var fileOut = new File( '/c/cutlines/'+ fileName.substring(0,fileName.length-4)+ '.txt');

but this does not work. What do I have to do different?

TOPICS
Actions and scripting

Views

1.1K

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
Valorous Hero ,
Apr 30, 2009 Apr 30, 2009

Copy link to clipboard

Copied

The path looks fine, but does c:/cutlines folder exist? if not it needs to be created.

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
Advisor ,
Apr 30, 2009 Apr 30, 2009

Copy link to clipboard

Copied

If you want the path to be absolutely identical on both OS X and XP, you will need

the folder c:/cutlines to be created on XP (as Paul noted) and the folder /c/cutlines to be created on OS X.

On OS X, this means creating a folder called 'c' in the file systems root directory with a subfolder called cutlines.

I have a couple of folders like that for some scripts I have laying around that still contain hardwired absolute paths.

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 ,
Apr 30, 2009 Apr 30, 2009

Copy link to clipboard

Copied

LATEST

Thanks for the help guys. I wasn't actually putting the files on C: it was actually going to a mapped network drive and for some reason last night the server was working incorrectly and that is where my problems where coming from. But that raises my next question, is there anyway to address the path with mapping the drive, so it would be a refence to the server. If i was browsing the path it would be TARHSHARE/PHOTOS/photos/DailyATS/Cutlines. With PHOTOS mapped to drive P the path is P:/Photos/Daily/ATS/Cutlines. So what I want to do is get it work without mapping the drive, so the script will work on all of the photographers accounts without mapping the drive.

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