How to open the files in subfolders"photo1,photo2,photo3"

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

JavierAroche
Posts: 29
Joined: Sat Jul 30, 2016 3:52 am
Location: San Francisco

Re: How to open the files in subfolders"photo1,photo2,photo3"

Post by JavierAroche »

That's really weird. Kukurykus' answer didn't show up until today. Glad you got it working! :)
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: How to open the files in subfolders"photo1,photo2,photo3"

Post by Kukurykus »

Yes, my answer came with delay...

bamboo, that first solution of me was quickly coded, now I have something more experienced.
It will scan more and more subfolders and won't stop the process when encounter non-graphical files.

As you see it's modiefed function of Mike Hall. Read more: viewtopic.php?f=65&t=24365

It's simplified and maybe uglified for some coders :), but I hope now it's enougth understable.
In the raport of scan it says name of last file in highest folder, but as to subfolder, it will be last deepest one.
Ah, and at the end choose wich version you prefer more (with eval or function) and delete one of them.

Code: Select all

var allFiles = [], sFolders = []

function scanSubFolders(tFolder) {
if (!sFolders.length) sFolders[0] = tFolder
var procFiles = tFolder.getFiles()
for(var i = 0; i < procFiles.length; i++) {
if (procFiles[i] instanceof File) {if (procFiles[i].fullName.search(/\.(jpg|tif|psd|bmp|gif|png)$/i) != -1) allFiles.push(procFiles[i])}
else if (procFiles[i] instanceof Folder) {sFolders.push(procFiles[i]), scanSubFolders(procFiles[i])}
}
return arr = [allFiles, sFolders]
}
scanSubFolders(topFolder = new Folder('~/desktop/test'))

// function style:
function EQL() {return eql ? 'ile' : 'older'}
for(var i = 0; i < arr.length; i++) {
var eql = arr[i] === arr[0]
alert('Scan of ' + topFolder + '\n' + arr[i].length + ' f' + EQL() + 's\nLast F' + EQL() + ': ' + arr[i][arr[i].length - 1])
}

// eval style:
var EQL = "(eql ? 'ile' : 'older')"
for(var i = 0; i < arr.length; i++) {
var eql = arr[i] === arr[0]
alert('Scan of ' + topFolder + '\n' + arr[i].length + ' f' + eval(EQL) + 's\nLast F' + eval(EQL) + ': ' + arr[i][arr[i].length - 1])
}
Last edited by Kukurykus on Tue Aug 02, 2016 3:57 pm, edited 1 time in total.
bamboo
Posts: 10
Joined: Fri Jul 29, 2016 7:14 pm

Re: How to open the files in subfolders"photo1,photo2,photo3"

Post by bamboo »

Thank you Kukurykus!!,I will lean more,thank you!!!