PhotoshopForums.com Home
Navigate Contact FAQ Search Members
Filenaming action or script
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation
 See a User Guidelines violation? Please contact us.
Author Message

paulslater3

Joined: 12 Aug 2013
Posts: 2



PostPosted: Mon Aug 12, 2013 12:12 pm    Post subject: Filenaming action or script Reply with quote

So here's what I"m trying to do:

I need to crop images at 2000 x 3000 with a filenaming convention of a_xxxyyyzzz.jpg. Then I need to crop that photo at 300 x 200 with a filemaing convention of b_xxxyyyzzz.jpg where the portion of the filename 'xxxyyyzzz.jpg" is identical to both the large and small images.

While the cropping will need to be manual since the aspect ratios are different, I feel there's a way to automate the filenaming.

The "a_" always needs to be associated with the large files and the b_ with the small files. The "a_" is easy to batch filename in Bridge of Photo Mechanic, but how would I swap in the "b_" for the "a_" while maintaining the rest of the filename for the smaller image?
View user's profile Send private message

paulslater3

Joined: 12 Aug 2013
Posts: 2



PostPosted: Tue Aug 13, 2013 9:23 am    Post subject: Reply with quote

Maybe this will help clarify.

I was previously using this script, but I no longer need to resize my images since I will be manually croppping a 2000 x 3000 and it's corresponding 300 x 250 image. All I need is once I crop my images, how can I batch rename them swapping the "i_" file prefix with a "t_" file prefix but maintaing the rest of the filename.

so I will batch name several images then crop in Photoshop at 2000 x 3000 with an "i_FullFileName.jpg".. THEN I will crop large thumbnails of those at 300 x 250 (manually) and I will want to swap the "i" with a "t" at the beginning of the filename while keeping the rest of the filename identical.

how can I tweak this script to do a Save For Web and swap any "i" with a "t" at the beginning of the filename?

thanks


app.preferences.rulerUnits = Units.PIXELS;

var srcDoc = app.activeDocument;
var imgNum = srcDoc.name.substring(2, (srcDoc.name.length)-4);
var myJpgQuality = 12

var sizeArray = [
[630, 420, "b_"],
[210, 140, "m_"],
[140, 93, "t_"]
]

for (var i=0; i<sizeArray.length; i++)
{
var shrinkWidth = sizeArray [i][0];
var shrinkHeight = sizeArray [i][1];
var mySaveName = sizeArray [i][2];

var id428 = charIDToTypeID( "Dplc" );
var desc92 = new ActionDescriptor();
var id429 = charIDToTypeID( "null" );
var ref27 = new ActionReference();
var id430 = charIDToTypeID( "Dcmn" );
var id431 = charIDToTypeID( "Ordn" );
var id432 = charIDToTypeID( "Frst" );
ref27.putEnumerated( id430, id431, id432 );
desc92.putReference( id429, ref27 );
var id433 = charIDToTypeID( "Nm " );
desc92.putString( id433, mySaveName );
executeAction( id428, desc92, DialogModes.NO );

activeDocument.resizeImage(shrinkWidth, shrinkHeight, 72, ResampleMethod.BICUBIC);
filePath = srcDoc.path + '/' + mySaveName + imgNum + '.jpg';
var jpgFile = new File(filePath);
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.formatOptions = FormatOptions.OPTIMIZEDBASELINE;
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = myJpgQuality;

activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
View user's profile Send private message

Matias Kiviniemi

Joined: 27 Sep 2013
Posts: 2



PostPosted: Fri Sep 27, 2013 11:42 am    Post subject: Reply with quote

Maybe I'm missing something you need, but can't you just iterate through app.documents, string replace "i_" with "t_" from doc name and do a save like you have in the script? Or then do a command line rename outside of PS?
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation All times are GMT - 6 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Contact - User Guidelines >

Copyright © 2003-2016. PhotoshopForums.com, iFroggy Network. All Rights Reserved.
Powered by phpBB © phpBB Group. phpBB SEO. Privacy Policy.
We are in no way affiliated with Adobe. Photoshop, Adobe and related marks are registered trademarks of Adobe.
PhotoshopForums.com