Photoshop JavaScript: open files in all subfolders

Hi guys

I'm new with javascript and General Photoshop scripts. My script is coming on well, but I have a hard time working with files and folders. It's a lack of knowledge of basic javascript, I need to work. Right now, I'm trying to expand the part open to the image of my script, so that it opens images in a subfolder or not.

You can see my entry folder (C:/entry). I want to be able to throw the files in there, some files in, others not. Out of curiosity, my outings will be combined into a single folder of output... which bit is fine.

var inFolder = new Folder("C:/Input")

if(inFolder != null){

var fileList = inFolder.getFiles(/\.(jpg|tif|psd|bmp|gif|png|)$/i);

}

for(var a = 0 ;a < fileList.length; a++)

{

var docRef = open(fileList[a]);

//do things here

}

Is there an easy way to extend this to include files in subfolders? Any advice greatly appreciated.

Thank you

David

You could combine the code you posted with the code I posted like this:

var topFolder = new Folder ('~/desktop/test');
var fileandfolderAr = scanSubFolders (topFolder, / \.) (jpg) | TIF | PSD | BMP | gif | PNG |) $/i);

List of files of the var = fileandfolderAr [0];

for (var a = 0;< filelist.length;="">

{

open = ([a] fileList) var docRef;

do things here

}

function scanSubFolders (tFolder, mask) {/ / folder, RegExp object or string}
var sFolders = new Array();
var allFiles = new Array();
sFolders [0] = tFolder.
for (var j = 0; j)< sfolders.length;="" j++){="" loop="" through="">
var procFiles is sFolders [j] .getFiles ();.
for (var i = 0; i)
If (procFiles [i] instanceof File) {}
if(Mask==undefined) allFiles.push (procFiles [i]); / / If no mask search does not collect all the files
If (procFiles [i].fullName.search (mask)! = - 1) allFiles.push (procFiles [i]); otherwise than those that correspond to mask
} ElseIf (procFiles [i] instanceof file) {}
sFolders.push (procFiles [i]); / / store the subfolder
scanSubFolders (procFiles [i], mask); / / Find the subfolder
}
}
}
return [allFiles, sFolders];
};

Tags: Photoshop

Similar Questions

  • Error opening file on all native projects SpeedGrade 2014/2015

    OK, it's frustrating and infuriating.

    I had to have my computer re-formatted, installed Win7 Ultimate and tried to get to the place where I 'was '. But at the present time, if I'm in 2014 Sg (build 8.0x141) or the new generation of 2015, I can't get any format/codec images to display a thumbnail in the browser "Desktop" of Sg and nothing added to the mounting area section just says "error opening file".

    Both will be run between a link Direct process.

    What the...! ?

    Neil

    I eliminated the ability of my media Speedgrade browser to show images trying to simulate (without entering the stage to add anything to the timeline)

    my media browser has been set to "sequences in the selected folder" and even if everything was showing according to the normal and me thinking as "sequences in the selected folder" was not what I had and going through the set up/view/format by default/coils/color space default - my media browser deleted

    Then, I chose "sequences of selected folder + subtree" and I found the ability to see my sequences of dng

    now I will go back to "sequences in the selected folder" and the files reappear

    I see not an MP4 Player until I select "all files", but I can put it on a timeline without error

  • Batching in Photoshop CS5 opens files in Camera Raw

    About directly from Photoshop CS5 (no bridge) of batch processing, I am unable to get the .dng files open without requiring that I click on "Open image" in Camera Raw.  I'm trying to run a simple step two sharpen more save and close action on a lot of 700 + .dng files.  There is no command in the action.  Thank you.

    You will probably need to check delete file Open Options dialogs.

    MTSTUNER

  • Adding a specific file to all subfolders on network drive

    How can I add the same folder all the files located on a network drive? For example, if I want to add a folder "Billing" to all customers on a disc records, how so without going into each folder and adding them one by one?

    PowerShell is my go to the source, this is a perfect example.

    http://community.Spiceworks.com/topic/473565-PowerShell-script-to-create-subfolder-in-all-folders-but-not-create-if-existing

    The first response also describes how to ignore if this folder already exists in the destination.

  • I canoe import videos in photoshop... I use a macbook, installed the quick time player... photoshop cannot open files... .any idea?

    ....

    What type of video file? Any errors? Information system and version? Version of Photoshop?

    Benjamin

  • open documents (or files) in the subfolders of the folder of my target

    Hi guys,.

    I'm new to javascript and I need help to open documents in subfolders of the folder of my target. There are several subfolders (subfolder 1 to 10 for example) contained in a folder ("Folder" in the script below). I want to open all the documents in a subfolder at a time and do something for these documents. Then close and open documents in a different subfolder (loop).

    I find a way to open documents that are directly under a folder. The problem is that I don't know how to open a document in the subfolder of a folder

    I need code that could do something like "getfolders" (but there is no such thing as 'getfolders') to the subfolder of 1 to 10 the number and loop through them to open documents.

    Could some please help me with the problem?

    This is where I am so far:

    #target photoshop

    Var folder = Folder.selectDialog ("select folder");

    If {(Folder)

    Uses of the var = theFolder.getFiles (/ \.) (jpg) | TIF | EPS | (psd) / $i);

    for (var m = 0; m < theFiles.length; m ++)

    {

    Open all documents in the folder

    var idOpn = charIDToTypeID ('Opn');

    var desc52 = new ActionDescriptor();

    var idnull = charIDToTypeID ("null");

    desc52.putPath (idnull, theFiles [m]);

    var ADI is charIDToTypeID ("As");.

    var idTIFF = charIDToTypeID ("TIFF");

    desc52.putClass (Adis, idTIFF);

    executeAction (idOpn, desc52, DialogModes.NO);

    ... do something for documents

    ... Save and close

    }

    }

    I finally get the correct script by combining small pieces from here and elsewhere

    After selecting the top folder, this script will go through each subfolder, one to a tim.e to open two files tif - that contain respectively the cy5 and texas. Then the script will superimpose the cy5 texas file file in a new RBG file and save it with a similar name that the file of texas except the overlay file will replace Texasred with overlay:

    #target photoshop

    app.bringToFront ();

    main(); call the main function

    main() {} function

    records of var = [];

    var topLevel = Folder.selectDialog("");  Select the superior folder

    if(topLevel == null) return; If you cancel to quit smoking

    records = FindAllFolders (topLevel, records);  call the FindAllFolders function

    Folders.unshift (topLevel);  Add new items at the beginning of an array

    for (var z = 0; z)< folders.length;="" z++){//="" loop="" through="" all="">

    List of files of the var = folders [z] .getFiles ("*.tif"); a list of all the hair in this subfolder

    for (var a = 0;< filelist.length;="" a+="">

    {//loop through all the files in the folder; 2 at a time

    If (fileList[a].name.match(/cy5/i)) {/ / the file must contain cy5}

    DocRef var = app.open (fileList [a])}; Open file

    If (fileList[a+1].name.match(/texas/i)) {/ / the file must contain Texas}

    var docref1 = app.open (fileList [a + 1]);} Open file

    * insert ' final script any overlay ", recorded by scriptistener

    Marker - Sep 17, 2016, 18:21:49

    // start=======================================================

    create a new custom RGB

    var idMk = charIDToTypeID ("Mk");

    var desc136 = new ActionDescriptor();

    var idNw = charIDToTypeID ('Nw');

    var desc137 = new ActionDescriptor();

    TSM var = charIDToTypeID ("Md");

    var idRGBM = charIDToTypeID ("RGBM");

    desc137.putClass (TSM, idRGBM);

    var idWdth = charIDToTypeID ("Wdth");

    var idRlt = charIDToTypeID ("#Rlt");

    desc137.putUnitDouble (idWdth, idRlt, 665.760000);

    var idHght = charIDToTypeID ("Hght");

    var idRlt = charIDToTypeID ("#Rlt");

    desc137.putUnitDouble (idHght, idRlt, 498.720000);

    var idRslt = charIDToTypeID ("Rslt");

    var idRsl = charIDToTypeID ("#Rsl");

    desc137.putUnitDouble (idRslt, idRsl, 150.000000);

    var idpixelScaleFactor = stringIDToTypeID ("pixelScaleFactor");

    desc137.putDouble (idpixelScaleFactor, 1.000000);

    idFl var = charIDToTypeID ("Fl");

    idFl var = charIDToTypeID ("Fl");

    var idBckC = charIDToTypeID ("BckC");

    desc137.putEnumerated (idFl, idFl, idBckC);

    var idDpth = charIDToTypeID ("Dpth");

    desc137.putInteger (idDpth, 16);

    var idprofile = stringIDToTypeID ('profile');

    desc137.putString (idprofile, "sRGB IEC61966 - 2.1");

    var idDcmn = charIDToTypeID ("Dcmn");

    desc136.putObject (idNw, idDcmn, desc137);

    executeAction (idMk, desc136, DialogModes.NO);

    end of the new creation of file marker - Sep 17, 2016, 18:22:19

    // start=======================================================

    perform the action for recovery

    var idPly = charIDToTypeID ('folds');

    var desc138 = new ActionDescriptor();

    var idnull = charIDToTypeID ("null");

    var ref90 = new ActionReference();

    var idActn = charIDToTypeID ('Actn');

    ref90.putName (idActn, "Overlay");

    var idASet = charIDToTypeID ("ASet");

    ref90.putName (idASet, "Default Actions");

    desc138.putReference (idnull, ref90);

    executeAction (idPly, desc138, DialogModes.NO);

    end overlay action marker - Sep 17, 2016, 18:24:08

    // start=======================================================

    Save the overlay file

    var idsave is charIDToTypeID ('save');.

    var desc139 = new ActionDescriptor();

    var ADI is charIDToTypeID ("As");.

    var desc140 = new ActionDescriptor();

    var idBytO = charIDToTypeID ("selonPour");

    var idPltf = charIDToTypeID ("Pltf");

    var idMcnt = charIDToTypeID ("Mcnt");

    desc140.putEnumerated (idBytO, idPltf, idMcnt);

    var idTIFF = charIDToTypeID ("TIFF");

    desc139.putObject (Adis, idTIFF, desc140);

    Marie Salomé var is charIDToTypeID ('In');.

    var name = list of files [a + 1].name.replace ("Texasred", "Overlay"); Rename the new file to overlay RGB

    desc139.putPath (Marie-Salomé, new file (files [z] + ' / ' + name));

    var idLwCs = charIDToTypeID ("LGD");

    desc139.putBoolean (idLwCs, true);

    executeAction (idsave, desc139, DialogModes.NO);

    end of file save marker - Sep 17, 2016, 18:26:43

    // start =======================================================

    Close all files

    var idCls = charIDToTypeID ("Cls");

    executeAction (idCls, undefined, DialogModes.NO);

    // =======================================================

    var idCls = charIDToTypeID ("Cls");

    executeAction (idCls, undefined, DialogModes.NO);

    // =======================================================

    var idCls = charIDToTypeID ("Cls");

    executeAction (idCls, undefined, DialogModes.NO);

    end of file closing marker - Sep 17, 2016, 18:27:43

    * end of the insertion of the script of any final overlay

    } //end filelist loop

    } //end loop of subfolders

    } //end main function

    function FindAllFolders (srcFolderStr, destArray) {}

    var fileFolderArray =. getFiles() folder (srcFolderStr);

    for (var i = 0; i)< filefolderarray.length;="" i++="" )="">

    var fileFoldObj = fileFolderArray [i];

    If (fileFoldObj instanceof File) {}

    } else {}

    destArray.push (Folder (fileFoldObj));  Add new items at the end of a table

    FindAllFolders (fileFoldObj.toString (), destArray);

    }

    }

    Return destArray;

    }

  • When open files in Photoshop CS6 files icons gone white with black box.

    When open files in Photoshop CS6 files icons gone white with black box. When I closed and exit the program, and then reopen its tracks for a few beautiful minute. but after half an hour, when I once again use Photoshop, it shows the error.

    Please give me a solution.screen shot.jpg

    All your windows updates are installed?  Try to clean the Windows thumbnail species.  I think use Adobe the OS dialog for features like open file. Also, to get thumbnails for RAW file PSD files, you will need to install codecs in windows. I use the fastepictureviewer codec package. What version of Windows are you using the dialog box look like a windows problem.

  • How can I fix the problem of not being able to open files by double clicking with photoshop

    How can I fix the problem of not being able to open files with photoshop by double-clicking it in windows Explorer?

    This problem affects psd, jpg, and png files.  I get an error saying "the program can't start because adbeape.dll is missing on your computer.  I can open all these types of files in the menu 'open' in photoshop.  It is not a matter of them not having no not extensions.  I use windows 7.

    Thank you

    Thanks for the update.

    Just for test, could you please rename Photoshop.exe to Photoshop CC2015.exe location: C:\Program Files\Adobe\Adobe Photoshop CC2015

    then change the file association to the new renamed exe file and let us know if this helps or not.

  • We just do the last update on Photoshop - that's why whenever we now open photoshop you have to select all the toolbars we want.  They used to be there for example, layers, tools, colors, etc., but now, we have to select each time

    We just do the last update on Photoshop - that's why whenever we now open photoshop you have to select all the toolbars we want.  They used to be there for example, layers, tools, colors, etc., but now, we have to select each time

    You look at the new start screen and files recent screen.  Press ESC to return to your usual workspace.

  • Why photoshop cs6 stopped opening files?

    Hello!

    Today, all of a sudden my photoshop cs6 stopped opening files. Drag & Drop and file > open... does not work. Only the system restart solved this but only for a while.

    Someone at - there a sulution for this problem? THX

    Hi mmatrix,

    Greetings.

    • Try to re-create preferences - restore preferences quickly by using a keyboard shortcut: press and hold Alt + Ctrl + Shift (Windows) or Option + command + shift (Mac OS) when you start Photoshop. You are prompted to delete the current settings. New preferences files are created the next time you start Photoshop
    • Open PS, click Help - updates and make sure your PS CS6 is up-to-date.
    • An update (if available), restart your computer.

    Concerning

    Rohit

  • Photoshop does not open files camera RAW

    Hello. I have the Canon 6 d and Photoshop CS6. Recently, I installed photoshop and have tried to import pictures from my camera to change. Whenever I try to import the photos (via file > open) an error message that says "Photoshop cannot open the file. "Make sure you have the latest version of the plug-in camera RAW. I've rechecked everything and I have all the latest software of Camera RAW in addition to fill all the updates on my computer (MacBook Pro 17-inch, version 10.10.5)

    Does anyone have any ideas as to why I am having this problem or how to fix?

    Thank you

    Click here to see if you have the correct version of ACR. Confirm if you can use it with your version of PS.

    Devices supported by Camera Raw

  • Photoshop cannot open EM5 II RAW files even with 8.8 ACR?

    I have a subscription Adobe CC so my Photoshop is already the latest version, but when I try to open EM5 II. ORF files, I get message "Photoshop cannot open this file." (see attached screenshot)Screen Shot 2015-04-03 at 3.32.55 AM.jpeg

    EM5 II is already officially supported according to the page Announces Camera Raw 8.8 then why can't Photoshop it open? I thought that there is something wrong with my setup so I downloaded and installed the plugin Camera Raw installation program manually, but the result is always the same.

    I even uninstalled my 2014 of CC in Photoshop using creative cloud and reinstalled, I get just the same message.

    All the other things I can try?

    Thank you. The link is on the same page that has been specified in my original post that I already downloaded and installed before but it didn't work.

    According to the instructions here Troubleshooting Camera Raw | Photoshop I uninstalled Photoshop CC and reinstalled and finally installed the plugin again and finally CameraRAW now it works!

  • I try to download a plug-in or patch to address the inability to open files in Photoshop CC 2014 RW2. Try AdobePatchinstaller, I get an error of installation. Any advise?

    I try to download a plug-in or patch to address the inability to open files in Photoshop CC 2014 RW2. I try AdobePatchinstaller but keep, we get an install error. Any advise?

    Thanks but the problem has been fixed. Adobe technical support led me through the process of updating all my apps.

    a r 2 0 1 4 o

  • «.. . not a Photoshop document valid"error opening file cc Mac on PC

    I get an error "Could not complete your request because it is not a Photoshop document valid." message every time I try to open a PSD file created on a Mac using Photoshop on my PC using CC CC. Other people have been able to open the file in the same place, so that the files are not corrupt. Someone knows how to fix this?

    I know this thread is a bit old, but I wanted to share my experience and solution in case anyone else runs into this.

    The other day, I spent many hours editing the photos for a client. I saved all and closed from Photoshop. When I tried to open the. PSD, they came all this "Not a valid Photoshop document" error. I capotais. I saw the thunmbnails and previews with the Mac OS Finder and could see the images in Lightroom, but couldn't open them in Photoshop CC.

    Finally, I remembered that they were NOT supposed to be .psd files! They were supposed to be the TIFFs. What happened was, when I edited coming in Lightroom in Photoshop, they opened as TIFF. However, when I did ' save under ', I wanted to name them in the same way to other files that I had. I clicked on one of the existing files to copy the name of the file in the Save dialog box as to make it easier to name the new file that I kept, but I didn't know it was change the name extension ".tif" to ".psd" file as well. The older MacOS (version 9 or earlier) do not rely on file extensions fo identification file types, so it didn't hit me right away this would be the problem. When I changed the extension of bad .psd file in .tiff, open files in Photoshop very well.

    Then... If you encounter this not "a valid Photoshop document" error, try to find out if it is actually another type of file (.jpg, .tif, .png, etc.) by getting the information from another file program or just experiment with different file extensions. Chances are good that your file is not actually corrupt, but just named incorrectly!

  • Cannot open files in Photoshop cs6

    I use PS CS6 through the creative cloud. When I try to open a file (RAW or JPEG), I can see the layer and the name of the file, but nothing is displayed in the work area. I tried to uninstall all Adobe products (I also use LR 4.3). A ran a registry cleaner twice and reinstalled PS with updates and 7.3 of the cab. This does not solve everything. Well open files in LR 4.3 and PES 10 before I uninstalled it. Any suggestions on what is the cause and how to fix it? Thank you

    What version of the OS?

    Have you tried to disable the GPU of drawing in Photoshop preferences?

    Have you updated your website of the manufacturer of the GPU video card driver?

Maybe you are looking for