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

Can I do this?

New Here ,
Jul 22, 2012 Jul 22, 2012

Hi all,

Im new to bridge scripting

I can code in actionscript, javascript so I should not have problems, but before getting in on it I'd like to know if the following is possible:

I'd like to do a script that:

- ask the user for a date (ddmm, for example=1907)

- ask the user for a folder on my pc

- for each Photocamera connected:

     - read a file inside the photocamera (in DCIM) named id.txt (a file that I placed manually)

     - read the content of the file and extract a string from it (the ID, let's say = "34")

     - read all subdirs contained in DCIM

     - find the subdir that ends with the provided date (for example: 107_1907)

     - copy all files from that subdir to the folder in my PC (set at the beginning) renaming files as hhmmss_ID.jpeg (hhmmss=picture creatione time) for example=124028_34.jpeg

is this possible?

thanks

TOPICS
Scripting
3.1K
Translate
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

Valorous Hero , Jul 26, 2012 Jul 26, 2012

If you wanted to try card readers, this should be a start for you...

#target bridge

if( BridgeTalk.appName == "bridge" ) { 

cardReader = MenuElement.create("command", "Process Card Reader", "at the end of Tools","cardReader");

}

cardReader.onSelect = function () {

var driveList = getCameraInfo();

var win = new Window( 'dialog', '' );

g = win.graphics;

var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);

g.backgroundColor = myBrush;

win.orientation='stack';

win.p1= win.add("panel", un

...
Translate
Valorous Hero ,
Jul 22, 2012 Jul 22, 2012

It sounds feasible as there is no specific Bridge scripting required, maybe a nice UI would help. You haven't said what version of Bridge as there as some problems with Bridge CS6 if you wanted to use colours/text size or use thumbnails in an UI.

Translate
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 22, 2012 Jul 22, 2012

thanks

I thought that Bridge's javascript was somehow proprietary and limited to

bridge's classes and methods... So, if I've well understood, Bridge will

interpret a normal javascript code that already supports html5 standards

like File and FileReader (otherwise there is no way to open/read local files), right?

Translate
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
Valorous Hero ,
Jul 22, 2012 Jul 22, 2012

Bridge and Photoshop use ExtendScript, It also has it's own IDE that gets installed with Photoshop.

ExtendScript Toolkit. You will find that there is help in the IDE also there are the PDFs in the Photoshop application scripting folder on Windows:

C:\Program Files\Adobe\Adobe Photoshop CS5 (64 Bit)\Scripting\Documents

As an example of creating a text file:-

var file = new File(Folder.desktop + "/Test Textfile.txt");

file.open("w", "TEXT", "????");

$.os.search(/windows/i)  != -1 ? file.lineFeed = 'windows'  : file.lineFeed = 'macintosh';

file.writeln("This is a line of text");

file.close();

Besides this forum you will find hundreds of examples @ http://www.ps-scripts.com/bb/

If you get stuck on anything please ask.

Translate
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 23, 2012 Jul 23, 2012

Thank you very much!

Your informations were very helpful for me.

I'm asking you a very last thing:

When I connect photocameras to my pc (I will connect about 60 of them), they are treated as "imaging device" and no driver letters are assigned to them.

I can see them on Bridge on the "my computer" folder and browse them. What I'm wondering is: will I be able to somehow access those devices? Do you know how since I cannot use any drive letter?

thanks again

Translate
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
Valorous Hero ,
Jul 23, 2012 Jul 23, 2012

To be honest, I don't know the answer to that as I have always taken the cards out and used a card reader. I will have to try putting one of the cameras to the computer and see what I get.

I wonder if you are using a Mac or PC?

Will get back to you once I've done a few tests....

Translate
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
Guru ,
Jul 23, 2012 Jul 23, 2012

He's on PC Paul… On a mac they would all be in volumes…

Translate
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 23, 2012 Jul 23, 2012

yes on PC, and thankyou very much for your help.

Translate
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
Valorous Hero ,
Jul 23, 2012 Jul 23, 2012

Thanks Mark, could you tell me if you can access any camera that is attached and get it's files?

I have tried on the PC and as ZRock2 has said they are Image Devices and I haven't been able to access them with JavaScript.

There is this..

http://www.codeproject.com/Articles/2303/WIA-Scripting-and-NET

Maybe this is the way forward to use c# ?

Or use a card reader.

By the way Mark could you test the Mac side of this code and correct it, to get the drive volumes, as you know I hate to switch on the Macs!

var myDrives=new Array();
if($.os.match(/win/ig)){
myDrives = getWinDriveList();
}else{
    myDrives = getMacDriveList();
}
alert(myDrives);

function getWinDriveList(){
var allHDD = new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
var hddExist = new Array();
for(var d in allHDD){
if(Folder("/"+allHDD+"/").getFiles("*.*").length > 0) hddExist.push(allHDD);  
    }
return hddExist;
};
function getMacDriveList(){
    return Folder("/Volumes").getFiles("*.*");
};

The PC side seems to work ok.

Translate
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 23, 2012 Jul 23, 2012

'ì saw that normally bridge use the bridge's "photo downloader" to import files from cameras,

do you think it would be possible to use that from code?

Translate
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
Valorous Hero ,
Jul 23, 2012 Jul 23, 2012

That code is part of Bridge and is not accessable. Most menu items are callable but this one isn't.

It looks as it not going to be an easy task to get the files direct from a camera.

A card reader is looking good

Translate
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 23, 2012 Jul 23, 2012

thanks,

searching and searching I found an adobe script called "import camera" that should do it,

I downloaded but 2 files were corrupted, I found one of them on the internet

but the other was the installation guide...

The problem is that there are 5 files

probably the main one would use the other as libraries or something but i dont know how to do that...

also i got problems understanding the code or finding the place where the files are imported...

(i just would need a copy&rename feature: i need to automatize importing and renaming from 60 cameras thats why i cannot use card reader)

Would you mind having a look?

I put it on server i have:

http://www.experience-3.com/ImportCamera2.rar

thx

Translate
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
Valorous Hero ,
Jul 24, 2012 Jul 24, 2012

This is a very old script, I think it was for CS2 or previous versions. I can get the UI up in CS3 (not in CS5/6) but it doesn't see the camera. It doesn't like Windows 7 either.

I will have another look at it tonight, as I have a netbook with XP and see if it works with that and CS3.

Translate
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
Guru ,
Jul 24, 2012 Jul 24, 2012

Paul, your code is fine on the mac… the mountpoints in /volumes does NOT include the bootdrive/partition but lists everything else… My mac has built in SD card reader but my camera is XD ( so I can't test ) but all devices should just mount at volumes regardless…

Translate
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 24, 2012 Jul 24, 2012

some news:

From what I've understood camera that do not presente themselves as hd, are trated via the WIA protocol.

Actually the images are just referable/enumerable but not accessible.

So what I'd need is some way to perform an automatic import of the pictures,

I searched 3 days on google but couldn't fine any software that permites a batch/scripting capture neither a capture command via command line...

The Adobe photodownloader is a separate exe (in the bridge dir) but not usable via command line...

tricky...

Translate
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
Valorous Hero ,
Jul 24, 2012 Jul 24, 2012

Thanks Mark, it's nice to know something works

ZRock2, it seems it is now Windows Portable Devices

I have found this but it's C#

http://cgeers.com/2011/06/05/wpd-enumerating-content/

Translate
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
Valorous Hero ,
Jul 26, 2012 Jul 26, 2012

If you wanted to try card readers, this should be a start for you...

#target bridge

if( BridgeTalk.appName == "bridge" ) { 

cardReader = MenuElement.create("command", "Process Card Reader", "at the end of Tools","cardReader");

}

cardReader.onSelect = function () {

var driveList = getCameraInfo();

var win = new Window( 'dialog', '' );

g = win.graphics;

var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);

g.backgroundColor = myBrush;

win.orientation='stack';

win.p1= win.add("panel", undefined, undefined, {borderStyle:"black"});

win.g1 = win.p1.add('group');

win.g1.orientation = "row";

win.title = win.g1.add('statictext',undefined,'Get Files from Card Reader');

win.title.alignment="fill";

var g = win.title.graphics;

g.font = ScriptUI.newFont("Georgia","BOLDITALIC",22);

win.g5 =win.p1.add('group');

win.g5.orientation = "row";

win.g5.alignment='fill';

win.g5.spacing=10;

win.g5.st1 = win.g5.add('statictext',undefined,'Camera');

win.g5.dd1 = win.g5.add('dropdownlist');

win.g5.st2 = win.g5.add('statictext',undefined,'Serial No:');

win.g5.dd2 = win.g5.add('dropdownlist');

win.g5.st2 = win.g5.add('statictext',undefined,'ID:');

win.g5.dd3 = win.g5.add('dropdownlist');

win.g10 =win.p1.add('group');

win.g10.orientation = "row";

win.g10.alignment='fill';

win.g10.st1 = win.g10.add('statictext',undefined,'Please enter date ddmm');

win.g10.et1 = win.g10.add('edittext',undefined,'');

win.g10.et1.preferredSize=[60,20];

win.g10.et1.onChanging = function() {

  if (this.text.match(/[^\-\.\d]/)) {

    this.text = this.text.replace(/[^\-\.\d]/g, '');

  }

};

win.g5.dd1.onChange=function(){

    win.g5.dd2.selection = this.selection.index;

    win.g5.dd3.selection = this.selection.index;

    }

win.g5.dd2.onChange=function(){

    win.g5.dd1.selection = this.selection.index;

    win.g5.dd3.selection = this.selection.index;

    }

win.g5.dd3.onChange=function(){

    win.g5.dd1.selection = this.selection.index;

    win.g5.dd2.selection = this.selection.index;

    }

win.g15 =win.p1.add('group');

win.g15.orientation = "row";

win.g15.alignment='fill';

win.g15.st1 = win.g15.add('statictext',undefined,'Please select output folder...');

win.g20 =win.p1.add('group');

win.g20.orientation = "row";

win.g20.alignment='fill';

win.g20.et1 = win.g20.add('edittext',undefined,'');

win.g20.et1.preferredSize=[320,20];

win.g20.et1.enabled=false;

win.g20.bu1 = win.g20.add('button',undefined,'Browse');

win.g20.bu1.onClick = function() {

  outputFolder = Folder.selectDialog("Please select the source folder",Folder(app.document.presentationPath));

if(outputFolder !=null){

  win.g20.et1.text =  decodeURI(outputFolder.fsName);

  }

}

win.g200 =win.p1.add('group');

win.g200.orientation = "row";

win.g200.alignment='center';

win.g200.bu1 = win.g200.add('button',undefined,'Process');

win.g200.bu1.preferredSize=[190,35];

win.g200.bu2 = win.g200.add('button',undefined,'Cancel');

win.g200.bu2.preferredSize=[190,35];

for(var x in driveList){

    win.g5.dd1.add('item',driveList[1]);//Camera Name

    win.g5.dd2.add('item',driveList[2]);//Serial Number

    win.g5.dd3.add('item',driveList[3]);//ID

    }

win.g5.dd1.selection=0;

win.g5.dd2.selection=0;

win.g200.bu1.onClick=function(){

if(driveList.length<1){

    alert("There are no drives to process!");

    return;

    }

if(win.g10.et1.text == ''){

    alert("No date has been entered!");

    return;

    }

var dayMonth = win.g10.et1.text.toString().replace(/^\s+|\s+$/g,'');

if(dayMonth.toString().length != 4){

    alert("The day month should be ddmm ");

    return;

    }

if(dayMonth.toString().match(/^\d{2}/) >31 || dayMonth.toString().match(/^\d{2}/) < 1){

    alert("Incorrect day entered");

    return;

    }

if(dayMonth.toString().match(/\d{2}$/) >12 || dayMonth.toString().match(/\d{2}$/) < 1){

    alert("Incorrect month entered");

    return;

    }

if(win.g20.et1.text == ''){

    alert("No output folder has been selected");

    return;

    }

if(!outputFolder.exists){

    alert("The output folder does not exist!");

    return;

    }

win.close();

var rex = new RegExp(dayMonth,'i');

var folderList= new Array();

for(var f in driveList){

var folderList= new Array();

folderList = FindAllFolders(Folder("/"+driveList[0]+"/DCIM/"), folderList); 

var ID = driveList[3];

var fileList = new Array();

for(var k in folderList){

    if(decodeURI(folderList.name).match(rex)){

        fileList = folderList.getFiles("*.*");

        for(var t in fileList){

            if(fileList instanceof Folder ) continue;

            var thumb = new Thumbnail(File(fileList));

            var md = thumb.synchronousMetadata;

            var EXT = decodeURI(thumb.spec.name).toLowerCase().match(/[^\.]+$/);

            try{

            var DateTimeOriginal = md.read("http://ns.adobe.com/exif/1.0/","exif:DateTimeOriginal").toString().match(/.{8}$/).toString().replace...);

            }catch(e){alert(e + " " +e.line); return;}

            var saveFile = File(outputFolder + "/" + DateTimeOriginal + "_" + ID + "." + EXT);

            fileList.copy(saveFile);

            }

        break;

        }

    }

    }

alert("Process complete");

}

win.show();

}

function getCameraInfo(){

var myDrives=new Array();

myDrives = getWinDriveList();

var cInfo = new Array();

for(var z in myDrives){

var folderList=[];

var ID='';

var IDFile = File("/"+myDrives+"/DCIM/ID.txt")

if(!IDFile.exists){

    ID=99;

    }else{

IDFile.open('r');

var dat = IDFile.read();

IDFile.close();

ID = dat.match(/\d{2}/);

        }

folderList = FindAllFolders(Folder("/"+myDrives+"/DCIM/"), folderList);

var thumb = new Thumbnail(File(Folder(folderList[0].getFiles("*.*")[0])));

var md = thumb.synchronousMetadata;

var model = md.read("http://ns.adobe.com/tiff/1.0/","tiff:Model");

var serial = md.read("http://ns.adobe.com/exif/1.0/aux/","aux:SerialNumber");

cInfo.push([[myDrives],[model],[serial],[ID]]);

    }

return cInfo;

}

function getWinDriveList(){

var allHDD = new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");

var hddExist = new Array();

for(var d in allHDD){

if(Folder("/"+allHDD+"/DCIM/").getFiles("*.*").length > 0) hddExist.push(allHDD);  

    }

return hddExist;

};

function FindAllFolders( srcFolderStr, destArray) {

var fileFolderArray = Folder( srcFolderStr ).getFiles();

for ( var i = 0; i < fileFolderArray.length; i++ ) {

  var fileFoldObj = fileFolderArray;

  if ( fileFoldObj instanceof File ) {  

  } else {

         destArray.push( Folder(fileFoldObj) );

  FindAllFolders( fileFoldObj.toString(), destArray );

  }

}

return destArray;

};


Translate
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 27, 2012 Jul 27, 2012
LATEST

Wow!

That's great! Thank you very very much, you solved me a big problem!

thanks again

Translate
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