{"id":1541,"date":"2012-02-08T20:33:58","date_gmt":"2012-02-09T02:33:58","guid":{"rendered":"http:\/\/www.wiredprairie.us\/blog\/?p=1541"},"modified":"2012-02-08T20:47:06","modified_gmt":"2012-02-09T02:47:06","slug":"adobe-lightroom-and-exporting-to-subfolders","status":"publish","type":"post","link":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1541","title":{"rendered":"Adobe Lightroom and exporting to subfolders"},"content":{"rendered":"

For some reason, versions 1 \u2013 3 of Adobe Lightroom cannot export images in a way that mirrors the original structure of your photo library. I can\u2019t offer a reason why other than it was missed by the development and design teams. There\u2019s been enough interest in it apparently that there are more than a few free and pay solutions to the problem. <\/p>\n

I looked at a few of the options and for one reason or another, I decided that I didn\u2019t want to use the plug-ins\/extensions and came up with a simple solution using a bit of naming trickery. I use this technique for SnugUp<\/a>.<\/p>\n

Here\u2019s what I did in Lightroom version 3.<\/p>\n

    \n
  1. I selected the photos I wanted to export.  (I generally use the Quick Collection Feature<\/strong>) <\/li>\n
  2. File<\/strong> > Export <\/strong>(CTRL + SHIFT + E) <\/li>\n
  3. Adjust the Export To<\/strong> option to point to a specific folder of your choosing (in the example below, I set the folder as E:\\PhotosBackupJPG
    \"image\" <\/li>\n
  4. You may optionally put them in a subfolder of your choice (I did not) <\/li>\n
  5. Next click the Rename To<\/strong> option and select "Edit\u2026<\/strong>\u201d
    \"image\" <\/li>\n
  6. Clear any value that may already be in the text box below the Example<\/strong> (just highlight the text and press delete).
    \"image\" <\/li>\n
  7. Then, edit the template to be Folder Name <\/strong>and then Original filename<\/strong>. Select those by using the Image Name grouping. Click the Insert <\/strong>button after each.
    \"SNAGHTML5521140b\" <\/li>\n
  8. Then, I added some text that I knew would be unique to be used as a separator (=-= <\/strong>equals minus equals). To add the text, just click with your mouse  between the two values you just inserted. I know that none of the file names in my library have this exact combination of characters in them. It\u2019s important later. You can confirm this by using the search feature in Lightroom if you\u2019re not sure.
    \"SNAGHTML5522af12\" <\/li>\n
  9. Click on the Preset<\/strong> (yours may say something else) and then click \u201cSave Current Settings as New Preset<\/strong>\u201d
    \"image\" <\/li>\n
  10. Give it a name that you\u2019ll remember (I called mine Folder-Filename) and hit Create<\/strong>.
    \"SNAGHTML5524784a\" <\/li>\n
  11. Adjust the remaining settings per your export needs and begin the process by clicking the Export<\/strong> button. <\/li>\n
  12. Wait patiently. Then go do something else as you realize it\u2019s going to take a lot <\/strong>longer than you had expected\/wanted. <\/li>\n
  13. Now, the next step is the simple trickery. What we\u2019ve done is named all of the files so that they include the folder name as well. So, using a Powershell 2.0 script (Powershell is available for all modern versions of Windows as part of a package download here<\/a>). So, download it now if you don\u2019t already have it. (You can check for it by looking for Powershell ISE as described in the next step if you\u2019re not sure. You probably have it if you\u2019re using Windows 7). <\/li>\n
  14. Start Windows Powershell ISE<\/strong> (in Vista and Windows 7, just type \u201cpower\u201d into the Start menu search):
    \"image\"The reason I suggest the ISE (integrated scripting environment) is that it\u2019s easy to just get stuff running without a lot of hassle. <\/li>\n
  15. The ISE will start:
    \"SNAGHTML552c2cf8\" <\/li>\n
  16. I performed the move\/rename in two steps so I could verify things between each step. If you\u2019re familiar with Powershell, feel free to combine them into one step. It\u2019s simple enough. First grab the entire script below and paste it into the top pane (under the tab labeled Untitled1.ps1<\/strong>):
    \n
    \n
    $root<\/span> <\/span>=<\/span> <\/span>#<\/span>"E:\\PhotosBackupJPG"<\/span>\n<\/span>$items<\/span> <\/span>=<\/span> Get<\/span>-<\/span>ChildItem <\/span>$root<\/span> \n<\/span>foreach<\/span>(<\/span>$item<\/span> <\/span>in<\/span> <\/span>$items<\/span>) {\n <\/span>$path<\/span> <\/span>=<\/span> [regex]<\/span>::<\/span>split(<\/span>$item<\/span>.Name, <\/span>"<\/span>(=-=)<\/span>"<\/span>)\n <\/span>if<\/span> (<\/span>$path<\/span>.length <\/span>-eq<\/span> <\/span>3<\/span>) {\n <\/span>$destPath<\/span> <\/span>=<\/span> <\/span>$root<\/span> <\/span>+<\/span> <\/span>"<\/span>\\<\/span>"<\/span> <\/span>+<\/span> <\/span>$path<\/span>[<\/span>0<\/span>]\n <\/span>if<\/span> (<\/span>!<\/span>(Test<\/span>-<\/span>Path <\/span>-<\/span>path <\/span>$destPath<\/span>))\n {\n New<\/span>-<\/span>Item <\/span>$destPath<\/span> <\/span>-<\/span>type directory\n <\/span>"<\/span>New folder: <\/span>"<\/span> <\/span>+<\/span> <\/span>$destPath<\/span>\n } \n Move<\/span>-<\/span>Item <\/span>$item<\/span>.FullName <\/span>$destPath<\/span>\n }\n}<\/span><\/div><\/pre>\n

    <\/div>\n

    I\u2019ve intentionally left an error in the file so that you\u2019re forced to make the change. Unless you have an \u201cE\u201d drive and the path, \u201cPhotosBackupJPG\u201d, the script needs a tiny modification to make it work. <\/li>\n

  17. The first line of the script, $root = #\u201dE:\\PhotosBackupJPG\u201d needs to be changed to match with the export location you selected earlier AND also the \u201c#\u201d needs to be removed (it\u2019s a comment character in Powershell script). So, if you exported your photos to C:\\Users\\Steve\\ExportedPhotos, remove the \u201c#\u201d and remove the text inside of the quotes on the first line and replace it with your photo location. <\/li>\n
  18. After confirming the location points to where you exported your photos (and videos), hit the Run <\/strong>button (the green arrow in the screen shot below). Or hit the F5 key on your keyboard.\n

    \"image\" <\/li>\n

  19. The output (or any errors if you made a typo) appears in the light blue box in the center and when it\u2019s complete, the word \u201cCompleted\u201d appears in the status bar at the bottom of the application. It may take a few minutes to complete. I\u2019d suggest looking at your export directory using Windows explorer to confirm everything looks fine before continuing. At this point, you should have some subfolders and all of the files should have been moved into the proper subfolder. Next, renaming. <\/li>\n
  20. Click the \u201cNew\u201d icon (first icon on left shown above) to create a new Powershell script file (or just replace the existing one, you won\u2019t need it again for this process). In the new file, copy this Powershell script and paste it:
    \n <\/p>\n
    \n
    $root<\/span> <\/span>=<\/span> <\/span>#<\/span>"E:\\PhotosBackupJPG"<\/span>\n<\/span>$items<\/span> <\/span>=<\/span> Get<\/span>-<\/span>ChildItem <\/span>$root<\/span> <\/span>-<\/span>recurse \n<\/span>foreach<\/span>(<\/span>$item<\/span> <\/span>in<\/span> <\/span>$items<\/span>) {\n <\/span>$path<\/span> <\/span>=<\/span> [regex]<\/span>::<\/span>split(<\/span>$item<\/span>.Name, <\/span>"<\/span>(=-=)<\/span>"<\/span>)\n <\/span>if<\/span> (<\/span>$path<\/span>.length <\/span>-eq<\/span> <\/span>3<\/span>) {\n <\/span>#<\/span> $destPath = $root + "\\" + $path[0]<\/span>\n<\/span> Rename<\/span>-<\/span>Item <\/span>$item<\/span>.FullName <\/span>$path<\/span>[<\/span>2<\/span>] \n }\n}<\/span><\/div><\/pre>\n

    <\/div>\n

    <\/li>\n

  21. Again, fix the $root to match with the export folder you created. <\/li>\n
  22. Confirm it, and hit the Run<\/strong> button. <\/li>\n
  23. All of your photos (and videos) will be renamed to only the original file name. The extra folder name and =-= are removed. <\/li>\n
  24. Bask in the glory of Powershell and your file wizardy. No plug-ins necessary. <\/li>\n<\/ol>\n

    If you\u2019d like to use something other than =-= as the delimiter between the folder and file names, you\u2019ll need to fix the Powershell scripts. The delimiter is on the line: <\/p>\n

    $path = [regex]::split($item.Name, "(=-=)"<\/span>) <\/p>\n

    <\/p>\n

    But, unless you understand how Regular Expressions in Powershell work, you may want to avoid this change \u2026 it\u2019s not necessarily as simple as just replacing the text.<\/p>\n

    The scripts above do these things with each file:<\/p>\n

      \n
    1. Check to see if it has the right pattern <\/li>\n
    2. If so, grab the folder name and check to see if the folder exists. <\/li>\n
    3. If it does not, create it. <\/li>\n
    4. Move the file to the new folder. <\/li>\n
    5. Rename the file name, removing the folder and delimiter <\/li>\n<\/ol>\n

      If you have questions, please leave a comment.<\/p>\n

      While this shouldn\u2019t cause any harm, (especially if you just point it at a folder of exported photos and videos, which worse case you just re-export), you use technique and code this at your own risk<\/strong>. I can say I successfully used the script on over 30,000 exported photos without a single problem. \"Smile\"<\/p>\n","protected":false},"excerpt":{"rendered":"

      For some reason, versions 1 \u2013 3 of Adobe Lightroom cannot export images in a way that mirrors the original structure of your photo library. I can\u2019t offer a reason why other than it was missed by the development and design teams. There\u2019s been enough interest in it apparently that there are more than a […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[11,8],"tags":[71,72,69,70],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pd5QIe-oR","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":600,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/600","url_meta":{"origin":1541,"position":0},"title":"Cameras and Lens, oh my!","date":"October 23, 2008","format":false,"excerpt":"My wife and I are doing a bit of international travel soon and I had decided that I\u2019d buy a new point and shoot camera to take with me. The trouble was that although there were a few new cameras out, none seemed to be available locally. I really like\u2026","rel":"","context":"In "Photography"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2008\/10\/image14.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1016,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1016","url_meta":{"origin":1541,"position":1},"title":"Silverlight vs. Flash vs. Photoshop Text Rendering","date":"March 24, 2010","format":false,"excerpt":"Curious about text rendering characteristics between Flash 10, Silverlight 4.0 and Photoshop, I created two small applications, one in Flash CS 4, and one in Visual Studio 2010. The Silverlight 4.0 tests are using the release candidate which was current as of March 23, 2010. I used Times New Roman\u2026","rel":"","context":"In "Coding"","img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2010\/03\/image_thumb.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1178,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1178","url_meta":{"origin":1541,"position":2},"title":"MSBuild Task Reference and Ajax Minification","date":"February 5, 2011","format":false,"excerpt":"I\u2019m not one for dumping all scripts into a single folder and calling it a day. The template project for ASP.NET MVC 3 does that unfortunately. So, after a bit of cleanup and adding a few more JavaScript libraries that I needed, I\u2019m left with a reasonably organized folder structure.\u2026","rel":"","context":"In "Coding"","img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2011\/02\/image2.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":917,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/917","url_meta":{"origin":1541,"position":3},"title":"Tom Bihn Smart Alec Backpack Review","date":"March 10, 2010","format":false,"excerpt":"I recently purchased a Tom Bihn Smart Alec Backpack. Tonight, I put it back in its original shipping box and will be shipping it back to Tom Bihn tomorrow. I wanted to review the bag here on my web site to provide some unbiased and alternative opinions to this bag\u2026","rel":"","context":"In "Recommendations"","img":{"alt_text":"IMG_0329","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2010\/03\/IMG_0329.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1329,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1329","url_meta":{"origin":1541,"position":4},"title":"My Nest Thermostat installation experience","date":"December 18, 2011","format":false,"excerpt":"After the amazing mad dash for the Nest thermostats when they were first made available for pre-order, I ordered three thermostats for our home from Best Buy (as Nest.com had sold out). We\u2019ve got a three zone heating system, and I wanted to replace all at once (as the system\u2026","rel":"","context":"In "Recommendations"","img":{"alt_text":"20111218-IMG_0096","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2011\/12\/20111218-IMG_0096_thumb.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1508,"url":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1508","url_meta":{"origin":1541,"position":5},"title":"Nest Thermostat Review, Update #9","date":"January 22, 2012","format":false,"excerpt":"Summary\/Index When I woke up this morning, I decided that I\u2019d use the remote features of my Nest Thermostat to increase the temperature of the first floor as the normal schedule hadn\u2019t started yet. Here\u2019s what I saw on my iPad: Basement: ? First Floor: ? When I tapped the\u2026","rel":"","context":"In "General"","img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/www.wiredprairie.us\/blog\/wp-content\/uploads\/2012\/01\/image23.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/posts\/1541"}],"collection":[{"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/comments?post=1541"}],"version-history":[{"count":3,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/posts\/1541\/revisions"}],"predecessor-version":[{"id":1544,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/posts\/1541\/revisions\/1544"}],"wp:attachment":[{"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/media?parent=1541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/categories?post=1541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wiredprairie.us\/blog\/index.php\/wpjson\/wp\/v2\/tags?post=1541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}