Hello!
I'm confused and mine mind is gona to explode
So i "made" one script which "convert" to images and then save as jpg. Problem is that it's theoreticly possible have 'someimage.tif' and 'someimage.psd' or .eps and etc. So saving without dialog just rewrites and leave one copy of such files. Which is not cool.
I get rid of converted folder overwrite problem and that was easy and don't quite understand why same method don't work to files.
Here is part of code:
var imageName = nameExt(image); // that's give filename without extension, copied from other site but it realy works (with one little touch)
var saveFile = new File(ConvertedFolder + '/' + imageName+'.jpg');
for (var i=1;saveFile.exists;i++) {
saveFile = new File(ConvertedFolder + '/' + imageName+'-'+i+'.jpg');
}
After that file is saved and closed.
I tried with 3 files with same name but diferent extension. If there is just these 3 files then it takes only 2 of them and don't even opens! 3rd. If there is some other image then it's make 5 copies form 2 of same images, like one of image not beeing copied but 2 other couple times.
At other hand if i cheat and use if then everything work just fine.
var imageName = nameExt(image);
var saveFile = new File(ConvertedFolder + '/' + imageName+'.jpg');
if (saveFile.exists) {saveFile = new File(ConvertedFolder + '/' + imageName+'-1.jpg')}
if (saveFile.exists) {saveFile = new File(ConvertedFolder + '/' + imageName+'-2.jpg')}
if (saveFile.exists) {saveFile = new File(ConvertedFolder + '/' + imageName+'-3.jpg')}
And this WORKS! I must been missing something but for my eyes those 3 IF can be transformed to FOR and it should do THE SAME! But it don't
So where is my obvious mistake?
Thanks!