Monday, October 14, 2013

How to categorize thousands of pictures from a single folder to multiple folders in 10 minutes?

How to categorize thousands of pictures from a single folder to multiple folders in 10 minutes?

This is first series of smart tips that come handy often; it’s about how to arrange thousands of picture/snaps that you take during your trip and wish to move them in day-wise folders. Have you been into such trouble of selecting and moving pictures in to date-wise folders from a huge list of images?

Well, I’ve purchased new Samsung handset and during initial two months I took around 3,300 pictures (my best friend’s marriage and my family trip to an exotic hill station was included too); pictures were huge and I was excited to show it to everyone however as the quantity was huge, I felt like bit boring to watching such huge of pictures in a single go so I decided to make folders of individuals and place pictures in day-wise structure so that we can enjoy complete journey.  Two months means sixty (60) days and around 3,300 pictures, hmm big problem? Isn’t!

In two months I can got that huge amount of pictures then think of what I could have gathered in an years ;) and what if someone wanted to arrange an years’ collection in such day-wise-folder-structure - it could take days in narration. Anyhow, you are smart and by now you might have understood that if I’m writing something here then I must have tried and sought solution already? You are getting smarter each day.

So, here is how to narrate pictures in shorted possible time slot:
  1. Arrange picture names somewhere where we can manipulate them. I use few old techniques of mine for doing such act; go to Command prompt (CMD for Win7 & Command for Windows XP) by typing it in RUN (Start -> Run) and hit enter. You will land in to dark room, console windows whose background is black and things fancy & mouse doesn’t perform any helpful function.
  2. Ok once landing in to command prompt, you have change path using its internal command; for example your picture folder is located in D driver then try these commands (CD\, D:, Cd Image_folder). If you follow then instruction properly then you will reach insight in the folder and path will look something like (D:\Image_folder\).
  3. Now type (Dir /a > List.txt) and hit enter; this will create a file (list.txt) in to the image folder which will include all files names along with data, folder, size etc. Now go to the folder and open this file in to notepad (I prefer notepad++ as it offer better options than simple notepad).
  4. Here is an example:
    • 10/13/2013  03:34 PM    <DIR>          .
    • 10/13/2013  03:34 PM    <DIR>          ..
    • 09/24/2013  01:17 AM           329,865 2013-09-24 01.17.02.jpg
    • 09/24/2013  03:21 PM           544,137 2013-09-24 15.21.34.jpg
    • 09/24/2013  03:21 PM           539,757 2013-09-24 15.21.36.jpg
    • 09/24/2013  03:23 PM           526,592 2013-09-24 15.23.00.jpg
  5. As you see that above details are totally messed up and difficult to work with and will take of time in setting them; well, that’s not the problem actually. One good thing about above data is that it’s in some kind of universal format or managed or standard format, observe it data – it contain data space-am/pm, lots of spaces, size, filename_date_time.jpg.
  6. Now copy all data from notepad to excel and remove all top/bottom junk details like <DIR> etc, keep only file name rows in the sheet. Now press CTRL+H (Find & Replace) and insert “*2013” in top input box and “2013” replace input box empty and hit replace all button. It will remove all data, am/pm, spaces and size from the data and only file name will be there. Once it’s done, it’s time to remove extra spaces by “Trim(A1)”. Here is how it will look like:
    • 20132013-09-24 01.17.02.jpg
    • 20132013-09-24 15.21.34.jpg
    • 20132013-09-24 15.21.36.jpg
    • 20132013-09-24 15.23.00.jpg
  7. Ok so now we have file name is excel sheet (time is part of file name so don’t worry about it); now it’s time to make separate time from date as we will be creating folders with date only. Now copy above data from sheet1 and paste it in sheet2 and press CTRL+H, insert “ *” (space & star) in first input box and keep the other input field empty and hit Replace all button. This will remove timestamp from file name, now go to Data->Remove Duplicates, this will remove all duplicates and keep only unique data which will use for making folders.
  8. Now move all unique folder names from A1 row to A2 and insert this term “md” in all A1 rows, now copy both rows (A1 & A2) and paste then in notepad. Pasting something from excel in to notepad copies some formatting as well, you will see that there will a TAB (\t invisible space) between “move” & “folder name” – copy that tab by selecting it and pressing Ctrl+C, now press Ctrl+H again and paste (tab) in first input field by pressing Ctrl+V and insert single SPACE in second input field and hit Replace All - this will fix the formatting issue.
  9. Save this file as “movefiles.bat”, go back to the folder and you will see a new file created with this name, just double click it and it will make lots of folders that we just arranged in excel.
  10. Sheet1 contains complete file names, sheet2 contains only unique folder names (if everything is fine by now); again, insert new columns (it will move A to B & B to C column), insert this word in A column “move”. Now in sheet1, copy all data from B1 column to C2 and select C2 column from the top and press Ctrl+H and enter “ *“ (space*) in first field and keep the second one empty and hit Replace All button. Now, column A contains word “move”, B contains complete file name and column B contains only folder name (not unique).
  11. Copy Column A, B & C and paste them in Notepad and replace all tabs with spaces (read point 8 for this); once tabs are replaced, save this as “movefiles.bat” and go to the image folder and double click (execute) this file; as soon you execute this file, it will execute few command prompt instructions and Walla! All files are moved to appropriate folders.
There are plenty of software for performing same action however it’s fun to know and understand how things work; this might look difficult initially, however once you have performed this twice then it won’t be a big deal in future and will save days work load! I could have made tutorials about performing same using iMacro or java scripting, however it is highly unnecessary to always go like a technical person if there are easy solutions available for same task.