Extract filename to external file

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Coinneach

Extract filename to external file

Post by Coinneach »

Hi,
I asked for help on here last year and you guys came up trumps, I hope you can help me again.

I'm looking to see if it is possible to extract the filename from a series of images and output the resulting list as a spreadsheet.
As an bonus, it would be great if the Author: field from the file info could be displayed beside the filename in a separate column.
In a perfect world the extension wouldn't show but if that's not possible I'd be happy to settle for having to delete it manually.


I co-ordinate images from various authors for competitions within my camera club and the club's now growing so the task becomes more onerous every time. Hand typing masses of titles can also lead to errors.

I don't have a clue how to start tackling this as I've never done any scripting.
I hope some kind soul(s) can help out.


Thanks

Kenny

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

Extract filename to external file

Post by Mike Hale »

I'm sure that Paul already has something that does what you want and will point you to it when he checks the forum. In the meantime have a look at http://ps-scripts.com/bb/viewtopic.php?f=19&t=2365 That is one of his scripts that I think should work for you.
Coinneach

Extract filename to external file

Post by Coinneach »

Thanks Mike for pointing it out.
Thanks Paul for creating it

is it asking too much to get some method of stripping the extension from the filename?

While I think of it I can do that in my spreadsheet software.


You've just made my day
txuku

Extract filename to external file

Post by txuku »

Hello Coinneach

I hoped that this code fits your needs:

Code: Select all//WriteDataCsv.jsx

//ouvrir un fichier .csv ou le creer
textFile = new File(File.openDialog("Open Text File to load","TextFile:*.csv;"));

//ouvrir le dossier des images a traiter
OpenFolder();

function OpenFolder(inputFolder)
{

        filesOpened = 0;

         //Boite de dialogue pour selectionner le dossier des images a traiter
         
        inputFolder =  Folder.selectDialog("Selectionner le DOSSIER DES IMAGES A TRAITER")

         //Autre solution :
         //Creer un sous dossier dans " /Mes images " ou mettre les images a traiter
         // et remplacer le mien " /Z_TRAITEMENT_TIFFS " par le votre.

         //var inputFolder = new Folder('C:',$.getenv('%HOMEDRIVE%%HOMEPATH%'))
         //var inputFolder= new Folder(inputFolder +"/Mes documents/Mes images/Z_TRAITEMENT_TIFFS")

         //Autre solution encore mettre l adresse complete avec le nom d USER a la place du mien " /moi "
         //var inputFolder = new Folder("C:/Documents and Settings/moi/Mes documents/Mes images/Z_TRAITEMENT_TIFFS");

        fileList = inputFolder.getFiles();

        for (  i = 0; i < fileList.length; )
        {
          open( fileList );
         
          ecrireDonnees() //le travail
          doc.close(SaveOptions.DONOTSAVECHANGES);  //fermer chaque image
   
          i++ 
         }
        return filesOpened;
}


function ecrireDonnees()
{
  doc = app.activeDocument;
  // Les infos a ecrire
  var Nom = doc.name.split(".jpg");
  Auteur = doc.info.author ;
  textFile.open("r");
  var line = textFile.readln();

  if (line.length<1)
  {
    alert();
    textFile.close();
    //ecrire les donnees
    textFile.open('a'); // 'a' et non 'w' pour ajouter les donnees sans ecraser les anciennes
    textFile.writeln('NOM IMAGE' + ';' + ';' + 'AUTEUR\n')
    textFile.writeln( Nom[0] +';'+';'+ Auteur ); // le ';' pour les colonnes
    textFile.close();
  }

  else
  {
    textFile.open('a'); // 'a' et non 'w' pour ajouter les donnees sans ecraser les anciennes
    //ecrire les donnees
    textFile.writeln( Nom[0] +';'+';'+ Auteur ); // le ';' pour les colonnes
    textFile.close();
  }
}