Quick Q: How to batch-rename folders based on EXIF data?
#1 : 08/07-25 05:18 Walden
Posts: 1
|
I would like to batch-rename a large number of photo folders ... pre-pending to each folder name the EXIF-embedded -create- date of the -oldest- file in each folder.
So for example, a folder called TestFolder whose oldest image was created on 2024-02-17 TestFolder Would be renamed 2024_02_17_TestFolder Is there a way to accomplish this? (on a batch basis of course) thanks for any guidance. |
#2 : 08/07-25 09:00 Delta Foxtrot
Posts: 519
|
Reply to #1:
Hi Walden, EDIT: You call this a quick question??? LOL! END EDIT I'm not sure what exif value you are looking to add to the folder name, but if you can live with the date in the "Created Date" column in the files list this script will approximate what you described. It won't rename the folders (that's not possible, exactly), but it will move all the files in each folder to a new folder made up of the old folder name plus the created date of the oldest file in each folder prepended to the folder name. I'm afraid that's the closest I can get to actually changing the folder names. You'll still have to do some cleanup, deleting the old (empty) folders, but if you have lots of files it will save you a ton of time and hassle. Here's what you'll need to do: 1. In a new ARen window, open a script method. Clear it if there's previous code. 2. Copy the code in the PRE-BATCH section below, then click on the "Pre batch script..." button and paste that code into the window. 3. Click "Close and apply". 4. Copy the code in the MAIN SCRIPT section below and paste it into the script main window. 5. Click "Apply script". 6. In windows explorer or whatever file manager you use, select the directories you want to rename and drag them to ARen. In the popup window select "Add the files in the folders". 7. ****** YOU MUST ****** >>> order the files by the "Created Date" column, by EARLIEST TO LATEST. (Just click on the Created Date column until the oldest file date of each folder is topmost... it's not a big deal :) I suggest that after you add the script parts you save the batch so you never have to find this forum thread and redo the first five steps. Also, once you load and order your files you should add the "New Path" column to your files list so you can preview where the files will end up (before running the batch). If you don't know how to add and move columns just ask. Ok, here's the script: // -------------- PRE-BATCH ------------------- p = app.getItem(0).path ; d = app.getItem(0).createddate.replace(/(\d{4})-(\d{2})-(\d{2}).*/, "$1_$2_$3_") ; // ----------------------------------------------- // -------------- MAIN SCRIPT ----------------- // if the current filename isn't in the path of the previous filename, // p and d change: if ( item.path != p ) { p = item.path ; d = app.currentItem.createddate.replace(/(\d{4})-(\d{2})-(\d{2}).*/, "$1_$2_$3_") ; } // get current item object: it = app.currentItem; // get the y/m/d part of the current item date, add _: dt = it.createddate.replace(/(\d{4}-\d{2}-\d{2}).*/, "$1_") ; // get current foldername: f = app.parseTags('<foldername>') ; // replace the current foldername with oldest date + current foldername: nf = item.path.replace( f, d + f ) ; // create newpath based on current path but with date in foldername: item.newPath = nf ; // ----------------------------------------------- Try this and see if it's what you need. Let me know the outcome either way. :) And if the "Created Date" value doesn't work for you let me know what you are looking for exactly, maybe I can fix it for you. Best, DF |