Folder and Sub-Folder Batch load Script

What I'm looking for I'm not ever sure is possible, but what I need is a script that will search for predefined sub-folder names within a specific "root" folder and run a script I have to load those images into a Photoshop document found within the root folder.  When loading these images, it will also need to place the images into a specific group within the Photoshop document, depending on the sub-folder that contained them.  So images in the sub-folder "A" need to be loaded into the group "A" in the Photoshop document, images in sub-folder "B" into group "B" and so-on.  The number and name of images within the sub-folders are, however, random; so this would also need to be accounted for.  Additionally, if possible, I would like the script to ask the user to locate this root folder each time before proceeding; otherwise, if not possible, a static folder location can also be used.  Thanks for any help!
dgolberg

Profile-mismatches as in: When the container document and the image to be placed are of different Color Spaces (different ICC-profiles).
Could you give this a try (on a copy of your files naturally); it places as Smart Objects (depending on your Photoshop > Preferences > General settings), but you could always rasterize after the import or chenge the preference in the Scripts and reset it at the end:
// place png-files from a folder and its contained folders with groups to represent those in jpg-files;
// 2011, use it at your own risk;
#target photoshop
// select folder;
var theFolder = Folder.selectDialog ("select folder");
if (theFolder) {
// get the jpgs;
var theJpgs = getJpgFiles(theFolder);
// iterate through the jpg files;
for (var m = 0; m < theJpgs.length; m++) {
var theDoc = app.open(new File(theJpgs[m]));
// thanks to xbytor;
var theName = theDoc.name.match(/(.*)\.[^\.]+$/)[1];
// place the png-files in groups coresponding to the folders;
placeFolderFiles(theFolder, theDoc, theName)
////// ceck for jpgs //////
function checkJpg (theFile) {
    if (theFile.name.match(/\.(jpg)$/i)) {
        return true
////// ceck for pngs //////
function checkPng (theFile) {
    if (theFile.name.match(/\.(png)$/i)) {
        return true
////// place //////
function placeScaleFile (file, xOffset, yOffset, theScale) {
// =======================================================
var idPlc = charIDToTypeID( "Plc " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    desc5.putPath( idnull, new File( file ) );
    var idFTcs = charIDToTypeID( "FTcs" );
    var idQCSt = charIDToTypeID( "QCSt" );
    var idQcsa = charIDToTypeID( "Qcsa" );
    desc5.putEnumerated( idFTcs, idQCSt, idQcsa );
    var idOfst = charIDToTypeID( "Ofst" );
        var desc6 = new ActionDescriptor();
        var idHrzn = charIDToTypeID( "Hrzn" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc6.putUnitDouble( idHrzn, idPxl, xOffset );
        var idVrtc = charIDToTypeID( "Vrtc" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc6.putUnitDouble( idVrtc, idPxl, yOffset );
    var idOfst = charIDToTypeID( "Ofst" );
    desc5.putObject( idOfst, idOfst, desc6 );
    var idWdth = charIDToTypeID( "Wdth" );
    var idPrc = charIDToTypeID( "#Prc" );
    desc5.putUnitDouble( idWdth, idPrc, theScale );
    var idHght = charIDToTypeID( "Hght" );
    var idPrc = charIDToTypeID( "#Prc" );
    desc5.putUnitDouble( idHght, idPrc, theScale );
    var idLnkd = charIDToTypeID( "Lnkd" );
    desc5.putBoolean( idLnkd, true );
executeAction( idPlc, desc5, DialogModes.NO );
return app.activeDocument.activeLayer;
////// place images in folder and contained folders //////
function placeFolderFiles (theFolder, theContainer, theName) {
          var theContent = theFolder.getFiles();
          for (var n = theContent.length - 1; n >= 0; n--) {
                    var theObject = theContent[n];
                    if (theObject.constructor.name == "Folder") {
                              var aFolder = theContainer.layerSets.add();
                              aFolder.name = Folder(theContent[n]).name;
                              placeFolderFiles(theObject, aFolder, theName)
                    if (checkPng(theObject) == true && theObject.name.match(theName)) {
                              var theLayer = placeScaleFile(theObject, 0, 0, 100);
                              theLayer.name = File(theObject).name;
                              theLayer.move(theContainer, ElementPlacement.PLACEATBEGINNING)
////// place images in folder and contained folders //////
function getJpgFiles (theFolder) {
          if (!theArray) {var theArray = new Array};
          var theContent = theFolder.getFiles();
          for (var n = theContent.length - 1; n >= 0; n--) {
                    var theObject = theContent[n];
                    if (theObject.constructor.name == "Folder") {
                              theArray = theArray.concat(getJpgFiles(theObject))
                    if (checkJpg(theObject) == true) {
                              theArray.push(theObject)
          return theArray

Similar Messages

  • Bug with workflow that creates a folder and sub folder with the same name.

    Hi,
    I've found a possible bug in SharePoint 2010 workflows. I only have access to SharePoint 2010 and SharePoint Designer 2010 over my companies intranet, afaik I don't have access to to logs or anything server side so sorry for the any missing information.
    I had some problems with a workflow in one list that needed to create some folders and subfolders in a second list. The production version did a lot more so I setup a test area with 1 list and a workflow that only does the folder creation part and have managed
    to consistently replicate this problem.
    The test list has two columns, [title] and [sub folder title]
    The workflow starts by getting the values for [title] and [sub folder title] into variables.
    It then creates a folder in the same list with the same name as [title], and then creates a sub folder under this with the name from [sub folder title]
    So the resulting structure would be:
    Test List:-
        List item with fields [title] and [sub folder title]
        [folder: title]:-
            [folder: sub folder title]
    If both folder names are different (e.g Folder1 and Folder2) then it works perfectly fine, if both folder names are the same (regardless of character case, e.g. samefolderName and sameFolderName) then the workflow fails.
    As part of the test i made the first action of the workflow to log the message "Workflow Started" to the history list. When the workflow fail there's nothing logged in the history list other than the error: "The workflow could not update the
    item, possibly because one or more columns for the item require a different type of information."
    Creating a sub folder with the same name as it's parent works fine manually but for some reason a workflow can't seem to do it in one action.
    As there's no history list entries before the error it looks like the workflow is just failing to start but if i do something like add an if statement to check if [title] and [sub folder title] are the same, and only create the subfolder when they are not
    then it runs fine doing what it's set to.
    The function of the workflow in our office was for convenience so were just working without it. Just wanted to post to see if anyone else has come across this/could try to replicate or explain this  and see if it's a SharePoint bug or something specific
    to our setup.
    thanks,
    Martin

    not sure about the specifics of your workflow, but if you're querying the list for the folders... keep in mind that a list lookup will only ever bring back ONE item... even if there are several items that meet the filter criteria... example: if i search
    a list for an item assigned to "john doe", there may be 15 tasks that meet the criteria, and it'll only grab one... this is why SP Designer WARNS you when your list lookup may exhibit this behavior.
    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com
    Strategic Data Systems - for all your SharePoint needs

  • Read All files in folder and sub folder

    Hi,
    i can read files in a folder,but not in a sub folders.can any one give me idea to read all files in the folder and its sub folder.
    Deepan

    Hi
    This code may help you
    Bliz
    import java.io.File;
    import java.io.IOException;
    import java.io.RandomAccessFile;
    import java.nio.channels.FileChannel;
    public class CountFiles {
          * @param args
          * @throws IOException
          * Count files in <path> and all its subDirs
         public static String path = "c:";
         public static String src1 = "";
         public static FileChannel channel;
         public static int numF;
         public static int numD;
         public static void main(String[] args) throws IOException {
              countFiles(path);
              System.out.println("Number of files :\t"+numF);
              System.out.println("Number of dirs :\t"+numD);
         public static void countFiles(String strPath) throws IOException
              File src = new File(strPath);
              if (src.isDirectory())
                   numD++;
                   String list[] = src.list();
                   try {
                       for (int i = 0; i < list.length; i++)
                        src1 = src.getAbsolutePath() + "\\" + list;
                        File file = new File(src1);
                        try {
                   channel = new RandomAccessFile(file, "r").getChannel();
                        }catch(java.io.FileNotFoundException e){}
                        countFiles(src1);
                   }catch(java.lang.NullPointerException e){}
              else
              numF++;

  • Loop through the excel files in folder and sub folder

    hi all
    I need to loop  through all the excel fies in a folder and its sub folder which contain excel files 
    actually, my excel files contain a column  with sdate and it contain different dates in which  has to get the max  date my query is 
    "select * from  @[User::filename] where sdate=(select max(sdate) asi  from @[User::filename] )"
    loop  all the excel file in folder and its sub folder

    Take a look at the Foreach Loop.
    Here is an article about it.
    Andy Tauber
    Data Architect
    The Vancouver Clinic
    Website | LinkedIn
    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click
    "Mark as Answer" and "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread.

  • Automating Group, Sub Group, Folder and Sub Folder Creation

    I am relatively new as an administrator, and this may be a simple question.
    I need to publish similar groups and folders for 30 instances. I am able to complete this through the CMS functionality, but I was wondering if there was some form of command line input or SQL statement I could use to add them instead. Automation of this process would provide a great time savings, so I am wondering if such a command line/batch file/SQL statement exist. My instance of Business Objects is run with A CMS attached to an Oracle database (if the SQL statement proves to be the answer).
    Thanks in advance for any assistance that can be provided.

    There is no simple command line utility to do this. This is possible via the Enterprise SDK though ([here|http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/devsuite.htm])

  • Can I import an entire folder and sub-folders at once?

    I am fairly new to LR and have TONS of files in a main Photo folder on Vista.  Some of these files have duplicate names, some were taken with very early gen digital camera as well as newer files with my 40D. But importing each folder and sub folder 1 at a time is going to take a million years.  Here is basically what I want to do.
    1) Import ALL pics (probably about 6-8 thousand) at once
    2) Go through these photos and tag them as well as get rid of the obviously crappy pics that i will never do anything with, kill the dupes
    3) Meta tag as many as i can
    4) export to a new foler
    All files are jpg.  Nice memorial day project eh?

    I would make some suggestions to your proposed workflow.
    Instead of "3) Meta tag as many as i can", I would say assign keywords and captions on all of your photos. Keywords and captions are a very powerful way of organizing, and when well done, they make finding your photos extremely easy. I understand that this takes time and effort, but you will find that the time and effort you put into this pays off well.
    If you leave some photos without keywords and captions, how will you find them? I know how ... you will search for 30 minutes and probably say some four-letter words in the process.
    Instead of "4) export to a new foler[sic]", don't bother exporting as a regular part of your workflow. Just don't do it! Only export when you need the photos outside of Lightroom, such as for e-mail or uploading or printing at a commercial printer. Otherwise, there is no need for you to take up the disk space with thousands of exported .jpgs.

  • My system preferences won't load. It opens straight up to the desktop folder and pictures won't load, leaving me with a color wheel. I've tried restarting my computer and that doesn't help. System preferences just won't open/load at all. Any ideas?

    My system preferences won't load. It opens straight up to the desktop folder and pictures won't load, leaving me with a color wheel. I've tried restarting my computer and that doesn't help. System preferences just won't open/load at all. Any ideas?

    Deleting the System Preference or other .plist file
    ..Step by Step to fix your Mac

  • 'Contacts' folder with sub folder cannot be removed after synching via iTunes

    'Contacts' folder with sub folder cannot be removed after synching via iTunes
    I am trying to remove a 'Contacts' subfolder
    ie Contacts < default folder
    - Contacts Mysubfolder 1 < Trying to remove this subfolder folder
    via my microsoft outlook onto my iPhone.
    Despite not having 'Contacts Mysubfolder 1' on my PC's outlook after deleting it, it does not delete the subfolder in my iPhone.
    I even restored my iPhone settings to the original via iTunes.
    I also replaced my physical iPhone but still synching with my original Apple ID + iTunes on the same desktop.
    All I did was after replacement of my iP, i setup my microsoft Exchange account, and there it was, the Contacts subfolder which is no longer around, appears on my iPhone contacts folder list.
    My outlook is on Microsoft exchange and I am on iP 3Gs
    Please help
    Thank you

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    If you are running 64-bit Windows and the above steps haven't helped try installing the version of iTunes that can be downloaded from this support document. iTunes 12.1 for Windows (64-bit — for older video cards)
    If you still have no luck try reinstalling iTunes 12.0, links in the user tip.
    tt2

  • How to create folder with sub folder ?

    How to create folder with sub folder ?

    Hi,
    Questions. 17 / 17 unresolved -> very bad reputation
    but ok - let's help anyway ...
    1. create everything in Screen Painter
    2. set FromPane and ToPane property correct.
    example:
    Items in MainFolder: FromPane & ToPane: 1 to 3
    Items in SubFolderA (From 2 To 2) - SubFolderB (From 3 To 3)
    shouldn't be that difficult
    in your Code set oForm.PaneLevel when the user clicks on the Folder
    lg David

  • FDM batch loader script

    x
    Edited by: user2657915 on Apr 16, 2012 10:15 AM

    Yes, you can use the batch loader to execute a SQL integration Script that is assigned to a location for import. You would create a blank text document with the proper file naming convention for batch files as noted in the FDM administrator guide and then place the files in OpenBatch and execute the batch via script or the GUI in the workbench. It will go to this POV and execute the Integration Script assigned to the location.

  • What would be the difference between sling:folder and nt:folder?

    what would be the difference between sling:folder and nt:folder?

    See,
       As Nicolas said, there are some things that you can do only in a sling:folder type of node.
       The "nt" means "Node Type", and a "node type: folder" is just a empty node that can be referenced as a organizational structure file folder. The "sling" prefix means that this one special folder belong to the type "Sling", in other words, that folder type node is built in the sling Framework structure and is constructed with some setting already, which I do not know to tell you. Take a look at "/libs/sling/nodetypes/sling.cnd" on you CRXDE Lite or CRXDE.
    (I may be wrong about some details, eveything here is what I believe myself after some research and experience)

  • This is regarding totals and sub totals in sap-scripts

    Hi to all...............
    1...How to print totals and subtotals in sap-scripts? where we have to code the logic.what sort of logic is needed to print the same?
    regards,
    swaminath.

    Hi
    HI,
    To calculate totals and sub totals in sap scripts you have to use subroutines.
    Say if you have to add the unit price (KOMVD-KBERT) then in the main window whereever tat value is picked write this routine
    /: DEFINE &TOT_PRICE&
    /: PERFORM F_GET_PRICE IN PROGRAM <subroutine prog name> /:USING &KOMVD-KBERT& /:CHANGING &TOT_PRICE& /:ENDPERFORM
    Then write the variable where ever you want it to be printed (mostly it will be in footer window)
    Then create subroutine pool program and you have to write the code.
    FORM F_GET_PRICE tables int_cond structure itcsy
    outt_cond structure itcsy. data : value type kbert.
    statics value1 type kbert.
    Read int_cond table index 1.
    value = int_cond-value.
    value1 = value1 + value.
    Read outt_cond table index 1.
    outt_cond-value = value1.
    Modify outt_cond index 1.
    ENDFORM.
    To know more, have a look at this thread ..
    Re: SAP Script: Display Total calculated  on page 2 in page 1
    <b>Reward if usefull</b>

  • I want to know the difference between iphoto master folder and previews folder

    I want to know the difference between iphoto library master folder and previews folder.. my pictures is stored in master but part of them is also copied into previews.. it occupied too much space.. if I can't change anything in iphoto library, any way to save the space for iphoto? 70G for almost 15,000 pictures, is it reasonable?
    i use mac book pro, ilife 11..

    70GB for 15,000 photos is reasonable, yes, if the photo files are large.
    DO NOT meddle with the contents of your iPhoto Library in any other way than using the commands available in the iPhoto application. What appear to be duplicate files stored in different parts of the library are NOT duplicates, and if you attempt to save space by deleting things in the Finder, you will wreck your library and land in a world of trouble.

  • Folder and Sub-Folders Action

    Hi,
    I want to automatically import into iPhotos all the new pictures that are added to a given folder and/or its sub-folders.
    To do that, I created a workflow saved as "folder action" that I attached to the root folder i want to watch. But how to make it be triggered as well on changes made to sub-folders?
    Thank you very much for your help and time.
    Greg

    Hi gregbul,
    I see... hummm I'm sure there is a way, unfortunatly I don't know anything about Script Editing so I have to limit myself to the options provided through Automator, and there doesn't seem to be any way to do what you want in Automator.
    If you select Edit Folder Action you will see the Script you created, there must be a way to edit the script so it includes the subfolders, but I have no idea how...
    Maybe you can try posting in the AppleScript Forum here:
    http://discussions.apple.com/forum.jspa?forumID=724
    I'm sure someone knows how to do this.
    Guylaine
    Mac mini Intel Core Duo 1.66 GHz 512MB DDR2 SDRAM   Mac OS X (10.4.8)   G4 Digital Audio Mac OS 9.2.2, iPod nano 1GB, iPod nano 4GB

  • How to find out how many items within folder (and sub folders)?

    Hi all,
    This may be a silly question - but if I have a folder (containing sub folders etc) is there a way to calculate how many file items are within this folder?
    I cant seem to do it using the info panel. And the standard view tells you how many file items are within the folder you are looking at, but not in the sub and sub sub folders etc.
    Thanks for any help!
    Paul

    or maybe
    SuperGetInfo
    http://www.barebones.com/products/super/index.shtml

Maybe you are looking for

  • Leopard sees 250Gb ATA slave drive as 128Gb...

    I have a 2001 QuickSilver 800Mhz DP tower, now upgraded to 1.8 Ghz DP (Newer Technology G4 7448 PPC). Also running an accelerated GeForce 7800XT 256Mb graphics card. Internally, I have 2 SCSI drives (70Gb and 140Gb) and 2 ATA drives (120Gb master and

  • Special ledger entries.

    Hi SAPGURUS, We have configured FI-SL settings for our client. Fiscal year variant --> same as calendar year both for FI-SL as well as normal postings. They needed data in the FI-SL tables from January' 2007. So we transferred the required data and e

  • 1.2 Update: Slow/choppy menu performance only while playing music?

    I picked up a 80GB iPod during the week.... I've noticed that the menus (namely smoothly scrolling through a long list of songs or artists) are quite smooth when not playing a song - but while you are playing a song, the meus become quite choppy/stut

  • WebDynpro ABAP Portal Integration

    Hello, i want to integrate a WebDynpro ABAP application from ERP 200 in the portal. There are several system aliasesdefinded in the portal. Anybody knows which system should be used to get a connection to the ERP 200 of the discovery system? Regards,

  • EXPORT_INCONSISTENT_STRUCTURE, runtime exception

    Hi, I am facing a problem when executing a function module in update task. I get an exception EXPORT_INCONSISTENT_STRUCTURE and the error analysis of the problem displays the following: "When exporting the structure description, the structure compone