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

Bridge 2022 - Rename Scripts

Community Beginner ,
Nov 25, 2021 Nov 25, 2021

Copy link to clipboard

Copied

Hello, 

I would like to be able to learn how to write a rename script on Bridge to do the following; first I want to know if this is something that's possible to do with bridge capabilities or what I could use to learn coding wise to write a script for it. 

Any info appreciated! 

 

Currently I have been doing it manually by duplicating the first image twice, running a batch rename with lower case and that gives me a b c d e - then use a automator function to delete the a + c but I am trying to simplify this process. 

 

Filename examples; files always follow this format but the digital counter is always random

1234567890123_000 ExampleNameRandom1.jpg

1234567890123_000 ExampleNameRandom2.jpg

1234567890123_000 ExampleNameRandom3.jpg

 

Output; desired out put to be in this sequence - not a + b + c + d + e instead b + d + e...etc

1234567890123_000_b

1234567890123_000_d

1234567890123_000_e

1234567890123_000_f

 

Regards,

 

TOPICS
Batch , How to , 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

correct answers 1 Correct answer

LEGEND , Dec 04, 2021 Dec 04, 2021

 

function re() {
	rplcd = fle.path + '/' + decodeURI(fle.name)
	.replace(/ .+(?=\.jpg)/, '_' + bdefgh.shift())
	return File(rplcd).name != nme && rplcd
}

rnmng = new MenuElement('command', 'Batch Renaming',
'at the end of Thumbnail'), rnmng.onSelect = function() {
	fls = File(pP = app.document.presentationPath).getFiles(/\.jpg$/i), cde = ''
	while(fls.length) ((slc = (nme = (fle = fls.shift()).name).slice(0, 17)) != cde) &&
	(cde = slc, bdefgh = 'bdefgh'.split('')), (rslt = re()) && fle.rename
...

Votes

Translate

Translate
Community Beginner ,
Nov 25, 2021 Nov 25, 2021

Copy link to clipboard

Copied

If its relevant the first 17 digits are always the same in the image batches - so batch 1 - will have the same 17 first digits then random digital counter, then batch 2 will have the same 17 first digits, etc. Only unique between batch of images.

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
LEGEND ,
Nov 25, 2021 Nov 25, 2021

Copy link to clipboard

Copied

function re() {
	return fle.path + '/' + decodeURI(fle.name)
	.replace(/ .+(?=\.jpg)/, '_' + (def.shift() || 'b'))
}

fle = File(Folder.desktop + '/1234567890123_000 ExampleNameRandom1.jpg')
def = 'def'.split(''); while(def.length) fle.copy(re()); fle.rename(re())

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 Beginner ,
Nov 27, 2021 Nov 27, 2021

Copy link to clipboard

Copied

Hello Kukurykus,

 

Thanks for taking the time to write this out - I am certainly going to try to digest it but currently this is way more advance than my brain. I am not even sure where to begin in running this or implementing it as usable tool. I am currently doing my results using two different substitution strings, but was wondering if it was possible to do it in one go. Are we allowed to post sample videos or images?

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
LEGEND ,
Nov 27, 2021 Nov 27, 2021

Copy link to clipboard

Copied

It's example how to do with only one file you have on your desktop.

Save it as OneFile.jsx and run with Br, however it works with Ps too.

Yes you can illustrate your problem by attaching videos and images 😉

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 Beginner ,
Dec 03, 2021 Dec 03, 2021

Copy link to clipboard

Copied

I tried your instructions but I could not get it to show up on bridge - I also did the reset preferences to see if it would show up but I can't see it on the menu? I can see it on the preferences and open it on visual code but can't get it to show up on bridge to run it. Going to see if I can get it to work on Photoshop! 

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
LEGEND ,
Dec 04, 2021 Dec 04, 2021

Copy link to clipboard

Copied

Okay, I'll do it easier for you. The following code save as "One File renaming.jsx" in:

C:\Program Files\Common Files\Adobe\Startup Scripts CC\Adobe Bridge 2022

After you launch Bridge you should be only one time asked to confirm the new script.

 

When you are in a folder with a file you want to change the way you described, right mouse click on that file and from dropdown menu choose last item called: 'One Time Renaming':

 

function re() {
	rplcd = fle.path + '/' + decodeURI(nme = fle.name)
	.replace(/ .+(?=\.jpg)/, '_' + (def.shift() || 'b'))
	return File(rplcd).name != nme && rplcd
}

rnmng = new MenuElement('command', 'One File Renaming',
'at the end of Thumbnail'), rnmng.onSelect = function() {
	if (!((slctns = app.document.selections).length - 1)) {
		def = 'def'.split(''); fle = slctns[0].spec; while
		(def.length) (rslt = re()) && fle.copy(rslt);
		(rslt = re()) && fle.rename(rslt)
	}
}

 

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 Beginner ,
Dec 04, 2021 Dec 04, 2021

Copy link to clipboard

Copied

@Kukurykus I have replied on the other post - which has the better explonation regarding the process. I am studying your code and using it as a learning tool to see if I can apply it to multiple files instead of one. 

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
LEGEND ,
Dec 04, 2021 Dec 04, 2021

Copy link to clipboard

Copied

Make sure the first part (to not be changed) of names of your (un)selected files are different:

 

function re() {
	rplcd = fle.path + '/' + decodeURI(nme = fle.name)
	.replace(/ .+(?=\.jpg)/, '_' + (def.shift() || 'b'))
	return File(rplcd).name != nme && rplcd
}

rnmng = new MenuElement('command', 'Batch Renaming',
'at the end of Thumbnail'), rnmng.onSelect = function() {
	fls = File(pP = (ad = app.document).presentationPath).getFiles(/\.jpg$/i); while(fls.length) {
		fle = fls.shift(), def = 'def'.split(''); while(def.length) (rslt = re()) && fle.copy(rslt);
		(rslt = re()) && fle.rename(rslt)
	}
}

 

If it works, due to your original request, close this topic by marking the solution as correct 😉

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 Beginner ,
Dec 04, 2021 Dec 04, 2021

Copy link to clipboard

Copied

Hey there! 

It's not working but I think I should close this topic - since I did not offer enough explonation on it and might be causing confusion! Your code is really helpful for me to study what it is doing though! 

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
LEGEND ,
Dec 04, 2021 Dec 04, 2021

Copy link to clipboard

Copied

I tried it on these files (while being in Bridge folder with them):

 

0111647050986_001 BLOUSE_0490.jpg

0112439780127_080 SHRUG_0869.jpg

0114433648110_024 HEM_0379.jpg

0114433648110_066 HEMUP_0381.jpg

0117648319170_012 HOODIE_0864.jpg

 

The script did same that version for single file, but not for one but all of them.

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 Beginner ,
Dec 04, 2021 Dec 04, 2021

Copy link to clipboard

Copied

Yes, in that sense it works. But it is making copies of the same file (first file) and then genrating copies renamed into that sequence. 

 

The idea is to take this for example. 

 

0111647050986_001 BLOUSE_0490.jpg
0111647050986_001 BLOUSE_0491.jpg
0111647050986_001 BLOUSE_0492.jpg
0112439780127_080 SHRUG_0869.jpg
0112439780127_080 SHRUG_0870.jpg
0112439780127_080 SHRUG_0871.jpg

 

And turn it into this. The regex extracts the first 17 digits of the original filename, and then renames them b,d,e,f,g,h if there is 3 images in this case, it renames it b,d,e only.

 

0111647050986_001_b.jpg
0111647050986_001_d.jpg
0111647050986_001_e.jpg
0112439780127_080_b.jpg
0112439780127_080_d.jpg
0112439780127_080_e.jpg

 

Would it be simpler to do a script that runs batch rename saved functions?

 

Run AUTO_RENAME_01.setting

Run AUTO_RENAME_02.setting

 

Instead of trying to do it in one step? I am not entirely sure what the limitations are, I apologize. 

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
LEGEND ,
Dec 04, 2021 Dec 04, 2021

Copy link to clipboard

Copied

 

function re() {
	rplcd = fle.path + '/' + decodeURI(fle.name)
	.replace(/ .+(?=\.jpg)/, '_' + bdefgh.shift())
	return File(rplcd).name != nme && rplcd
}

rnmng = new MenuElement('command', 'Batch Renaming',
'at the end of Thumbnail'), rnmng.onSelect = function() {
	fls = File(pP = app.document.presentationPath).getFiles(/\.jpg$/i), cde = ''
	while(fls.length) ((slc = (nme = (fle = fls.shift()).name).slice(0, 17)) != cde) &&
	(cde = slc, bdefgh = 'bdefgh'.split('')), (rslt = re()) && fle.rename(rslt)
}

 

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 Beginner ,
Dec 06, 2021 Dec 06, 2021

Copy link to clipboard

Copied

Hello @Kukurykus I got this to work on my windows Bridge 2022 - but I could not get it to work on my iMAC Bridge 2022 - any idea what I need to look out for to get it to work on there as well?

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
LEGEND ,
Dec 06, 2021 Dec 06, 2021

Copy link to clipboard

Copied

To solve as I guess macOS rename() problem, change fle.rename(rslt) to newThumbnail() and under re() function add another one, that's going to remove old jpg to create new one instead, how ever without metadata:

 

function newThumbnail() {
	bm = new BitmapData(new Thumbnail(fle).spec)
	fle.remove(), bm.exportTo(File(rslt), 100), bm.dispose()
}

It works slower, but it works unless perhaps system file permission was a problem.

 

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 Beginner ,
Dec 06, 2021 Dec 06, 2021

Copy link to clipboard

Copied

This worked! It is considerably slower - but it worked! Thank you! 

What should I check in terms of permissions to see if I can get the other one to work? Would it have to do with file & folder persmissions within bridge or something else? I gave Bridge full access to see if it would work and it wouldn't work. 

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
LEGEND ,
Dec 06, 2021 Dec 06, 2021

Copy link to clipboard

Copied

Browse Bridge community for macOS permissions. Probably there are some posts about it.

 

You may also make some simple rename() operation on single file to see whether it works.

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 Beginner ,
Dec 06, 2021 Dec 06, 2021

Copy link to clipboard

Copied

LATEST

Thank you so much for all of your help Kukurykus!!! Life saver! 

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