Copy link to clipboard
Copied
Hi
I am trying with my own action using marquee selection tool i used to select an area of an image and run the action it just crop the area and duplicates it as seperate image but with same file name copy.I want to know is there any option to save a file as jpeg in the series of continuity numbers like "1-10" with its own name via ETSK.
For example :
My images have their names like :
784595.Q0JBHNNM.BB1.jpg,
658589.U0JBHNKLJ.BA1.jpg.
My images are always had the naming structure like this but i need it to be duplicated into separate document and naming structure as Center part of the source file name "Q0JBHNNM" and by adding the suffix from 1-10 in the file name depends upon the how many i select and run the script.
(So the file names will be like Q0JBHNNM.01.jpg,Q0JBHNNM.02.jpg)
Anyone help me on this.
Thanks in advance.
Copy link to clipboard
Copied
Actions have a hard time naming files they save. Photoshop has features like Batch and Photoshop scripting that the action creator can used to help save files the manes they need. IMO Your best option is to download and install the plug-in Image Processor Pro. Add-on. Once that is installed you can use it from bridge menu tools and Photoshop menu File>Automate>Image Processor Pro... You can have the Image Processor process the image files you want to process and save the output File Types you need to save with the File Names you want. Image processor pro can save many image file types and has very flexible file naming options. For each output File you need to save you can have the Image processor include a simple action you create to customize the processing done. You can easily do the cropping you do in you current actions and use the Image Processor file naming option to save the file with names to suit you needs.
Copy link to clipboard
Copied
It's best not to use "." in your file name other than for the extension. a "-" or "_" would be better. You can change the number by making a count variable or a variable in a loop then looping and incrementing the count by one eachtime:
var doc = activeDocument;
var fileBaseName = doc.name.split('.')[0];
for(var i=1001;i<10;i++){
var newFileName = fileBaseName + '.' + i.toString ().substr (2) + '.jpg'
}
Edit: corrected line 2.
Copy link to clipboard
Copied
var doc = activeDocument;
var fileBaseName = doc.name.split('.')
// Define JPG export settings
var JPGSettings = new JPEGSaveOptions();
JPGSettings.quality = 12;
for(var i=1001;i<10;i++){
var newFileName = fileBaseName + '.' + i.toString ().substr (2) + '.jpg'
// Save file as JPG
doc.saveAs(newFileName, JPGSettings, true, Extension.LOWERCASE);
}
I have used like this but not saving as a copy of the image in series of names Can u please help me
Copy link to clipboard
Copied
Hi Chuck Uebele
are you really sure, that your code works?
I think, this could be a little bit better
var doc = activeDocument;
var fileBaseName = doc.name.split('.');
for(var i=1000;i<1110;i++) {
var newFileName = fileBaseName[1] + '_' + i.toString ().substr (1) + '.jpg';
}
Copy link to clipboard
Copied
Opps, forgot to select the first element of the array. Thanks.
Actually, pixxxel shubser, I think in you code in line 4, you need
Copy link to clipboard
Copied
And your counter in the loop (i<10; i++ ) is a bit odd.
(But now the TO got two variants, with two and with three digits)
Kindly regards
edit (because of your edit)
array[0] gives you 784595 but I thought Q0JBHNNM is the base name?
Copy link to clipboard
Copied
Yea, I was thinking of number 1-10, but I should have changed the loop as it will only go to 9.
Copy link to clipboard
Copied
At the end:
var doc = activeDocument;
var fileBaseName = doc.name.split('.');
for(var i=100; i<=110; i++) {
var newFileName = fileBaseName[1] + '_' + i.toString ().substr (1) + '.jpg';
}
Copy link to clipboard
Copied
it creates a snapshot in history palette but not exporting them as separate jpg files like Q0JBHNNM-01,Q0JBHNNM-02,Q0JBHNNM-03,etc
i dont know why??
Here is the code whats wrong in this??
#target photoshop
var doc = activeDocument;
var fileBaseName = doc.name.split('.');
// Define JPG export settings
var JPGSettings = new JPEGSaveOptions();
JPGSettings.quality = 12;
for(var i=100; i<=110; i++) {
var newFileName = fileBaseName[2] + '_' + i.toString ().substr (1) + '.jpg';
// Define new file path
var JPGName = new File(doc.path + fileBaseName[2] + '_' + i.toString ().substr (1) + '.jpg');
// Save file as JPG
doc.saveAs(JPGName, JPGSettings, true, Extension.LOWERCASE);
};
Copy link to clipboard
Copied
Oops its now its working but actually what the problem is the script loops to ten times and save as a 10 different jpgs automatically but what i want to do is if i crop the area on a image and run the script it will as Q0JBHNNM-01.jpg
incase if crop another of same image then only the script would save the image as Q0JBHNNM-02.jpg
Otherwise no need to save those remaining counts.
Copy link to clipboard
Copied
We just gave you the basics for creating the loop to save the files. You to add any additional code for cropping.
Copy link to clipboard
Copied
can u please me how to do that i am confused while using selection if i select an area in the image and run the image should save as 1 and if select and run the 2 nd area of my image it should save into another image as 2
Please help me out !
Copy link to clipboard
Copied
What all are you trying to do? When you run a script, it needs to run it's course before you can do any non repetitive editing. You can code in various things like always cropping, or making a selection. It's pretty much like an action in that regard. You can change it so it stops to let you manually set the parameters of things like cropping then continue. If you want to do a bunch of different edits then have the script save the file with the next number, you need to either create a script that stores the next number in a csv or xml file, or have all the files saved in a base folder and have the script read the names of the files to select the what would be the next one.
Copy link to clipboard
Copied
Okay but the codes save the same image into ten times i just need that function to be run on save as event.
Copy link to clipboard
Copied
so if i use the above script whether it would replace the same image name or save as a different image and name.
Copy link to clipboard
Copied
It should create a new file with a new name, unless you have a file already named with the first part of the file before the "." and a number 01 - 10.