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

Best approach to read and export channel names? Ideally into a database of some sort.

New Here ,
Dec 08, 2023 Dec 08, 2023

Copy link to clipboard

Copied

In this context, channel layers are used in a way where they are individually printed onto physical media and labelled with the name of the channel. 

 

To save time manually opening each file and copying the channel names, is there a way to export those names out of a .PSD file programmatically to save into either a csv or into a database?

 

What's the best approach to get the names  of a channel in a Photoshop .psd?

 

 

TOPICS
Actions and scripting , Web , Windows

Views

110

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

Community Expert , Dec 08, 2023 Dec 08, 2023

@virakones 

 

I'm not sure if this is the "best approach", but it's "an approach"... I had all the bits required from other scripts, so it was just a case of a few copy/pastes and some refactoring. The CSV will be written to the desktop using the active Photoshop document name as a prefix:

 

/*
Log channel names to CSV.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/best-approach-to-read-and-export-channel-names-ideally-into-a-database-of-some-sort/td-p/14287022
*/

#target ph
...

Votes

Translate

Translate
Adobe
Community Expert ,
Dec 08, 2023 Dec 08, 2023

Copy link to clipboard

Copied

@virakones 

 

I'm not sure if this is the "best approach", but it's "an approach"... I had all the bits required from other scripts, so it was just a case of a few copy/pastes and some refactoring. The CSV will be written to the desktop using the active Photoshop document name as a prefix:

 

/*
Log channel names to CSV.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/best-approach-to-read-and-export-channel-names-ideally-into-a-database-of-some-sort/td-p/14287022
*/

#target photoshop

var os = $.os.toLowerCase().indexOf("mac") >= 0 ? "mac" : "windows";
if (os === "mac") {
    logFileLF = "Unix";
} else {
    logFileLF = "Windows";
}
var sourceDocName = activeDocument.name.replace(/\.[^\.]+$/, '');
var logFile = new File("~/Desktop/" + sourceDocName + "_Channel Names.csv");
if (logFile.exists)
    logFile.remove();

// Loop backward to reverse channel order
//for (var i = activeDocument.channels.length - 1; i >= 0; i--) {
// Loop forward
for (var i = 0; i < activeDocument.channels.length; i++) {
    try {
        logFile.open("a");
        logFile.encoding = "UTF-8";
        logFile.lineFeed = logFileLF;
        // Doc name, channel name
        //logFile.writeln(activeDocument.name.replace(/,/g, '-') + "," + activeDocument.channels[i].name.replace(/,/g, '-'));
        // Channel name
        logFile.writeln(activeDocument.channels[i].name);
        logFile.close();
    } catch (e) {
        alert(e + ': Line ' + e.line);
    }
}

logFile.execute();

 

 

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 ,
Dec 08, 2023 Dec 08, 2023

Copy link to clipboard

Copied

@Stephen_A_Marsh 

This worked beautifully! Thank you so much for the suggestion, it's a great launching point for me

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 ,
Dec 08, 2023 Dec 08, 2023

Copy link to clipboard

Copied

LATEST

You're welcome. As there was no example txt file I had to take a guess with a single column. It could just as easily be two columns, the first being the file name and the second the channel name.

 

Please mark my previous post as a correct answer if it answers your question, thanks.

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