watch folder + IPTC rename

General Discussion of Scripting for Adobe Bridge

Moderators: Kukurykus, Tom, xbytor

Posts: 1
Joined: Tue Dec 13, 2016 9:02 am

watch folder + IPTC rename

Post by bwpxyz »

I haven't written any Bridge scripts before so any help appreciated!

I have an imaging workflow where 6 cameras each take a picture at the same time, followed by a short pause (around 20 seconds) and then take another batch of images.

I need a script to watch a folder and rename the 6 images based on the IPTC metadata (IPTC field "Creator" in Bridge), and then move the 6 images to a second folder (where another program will take over additional processing/renaming).

The batch rename in Bridge is perfect, except it doesn't have a watchfolder/hotfolder function.

Thanks in advance!

User avatar
Posts: 8
Joined: Fri Aug 19, 2016 2:24 pm
Location: Portugal

Re: watch folder + IPTC rename

Post by pedro.marques »

Hi, this is possible on Bridge on these conditions:

- you have a computer free just to do that, with no user intervation;
- you have Bridge allways active and on focus on the watch folder;
- be sure the system has no sleep mode active;

The base code you need is in here and you just need to add your code where is indicated.

Select a folder on your network to be the "hotFolder" (you can change its name and in the code itself);
On the computer that will be the listener over the hotFolder, just put this code on the Bridge "Startup Scripts" folder and reopen Bridge
Using another computer, put some images in the folder "hotFolder" and check is the listener event handler reacts automatically.
You can then add your code in the lines (see line 25) or use the file as an argument to run other code you want;
In the end, after the file was processed, just move it or remove it;
This listener will be triggered anytime a file is added or removed or the cache is refreshed. It works only on a folder called "hotFolder";

Hope it helps,

More info in here:

Code: Select all

var listenerHotFolder = function( event ) {  
// IMPORTANT: $.hiresTimer > 180000 this will make sure to trigger only once on cached folders like the hot folder, because when a file is detected it trigers twice (start building cache and finishing building cache).
if ( event.object instanceof Document && event.type == 'loaded' && $.hiresTimer > 180000) {
// only works if the active folder name is "hotFolder" case sensitive
if ( == "hotfolder") {
var myFiles_array = [];
// if doesn't exist, creates a subfolder to move the active processing files
var processingFolder = Folder(app.document.presentationPath + "\\processing");
if (!processingFolder.exists) processingFolder.create();
// You can change the image kind you want to deal with, or other file kind
var items = Folder(app.document.presentationPath).getFiles( function(f) { return (f instanceof File &&\.dng|cr2|jpe?g$/) != null);}); // JPG | CR2 | DNG
for (var a=0 ; a < items.length ; a++) {
var copied = File(decodeURI(items[a])).copy( File(File(decodeURI(items[a])).path + "/processing/" + File(decodeURI(items[a])).name ) );
if (copied) {
$.writeln(File(File(decodeURI(items[a])).path + "/processing/" + File(decodeURI(items[a])).name ).fsName)
myFiles_array.push(File(File(decodeURI(items[a])).path + "/processing/" + File(decodeURI(items[a])).name ).fsName);
// if files were dropped on the hotFolder, and were collected, any script can be running on each file.
if (myFiles_array.length > 0) {
for (var a=0 ; a < myFiles_array.length ; a++) {
// here you can put your code

// this is just an exemple to test (you can delete this later:
alert("Processing the File:\n" + File(decodeURI(myFiles_array[a])).name);

return {
// FALSE + block last path repetition »» só repete o evento numa numa pasta (não repete em F5 ou em cache rebuild) Resumo: sá actua se navegar numa nova pasta
// TRUE + block last path repetition »» repete em várias situações: numa nova pasta, ao criar/apagar ficheiros/pastas no folder activo, ao reordenar a primeira vez (qd cria a primeira vez o file invisivel .bridgesort)
app.eventHandlers.push( {handler: listenerHotFolder} );

Posts: 1
Joined: Tue May 16, 2017 3:35 pm

Re: watch folder + IPTC rename

Post by Ethan »

Thanks, that's a great and very useful scrip. can this be updated to watch two folders (or more) at the same time?
Help will be appreciated.