How to merge folders with non-duplicating files?

Post any Bulk Rename Utility support requirements here. Open to all registered users.

How to merge folders with non-duplicating files?

Postby Stars » Wed Oct 17, 2018 1:47 am

I am not very good at expressions or so, and usually do minor folder renaming for my vacation and similar photos folders. My camera does add the month/day at the end of folder name, however the beginning goes 100_0725; 101_0728 and so (sequentially). A simple solution is to remove three first symbols of selected folders and add year (e.g. 2018) at the beginning at the same time. However, the fun begins when camera creates several folders for the same day, so I may have 105_0731; 106_0731; 107_0731. The file names in the folders are sequential and do not repeat, so I want to have one 2018_0731 folder, and not 3 or 5 or how many the camera did create, and I need only to merge folders.

If I try a simple rename, I get the message that rename cannot be performed because of duplicating names and told to mark the checkbox "Prevent Duplicates". I also tried checkbox "Overwrite/Delete Existing Files". Nothing helps. I tried searching in help and here, but did not find anything matching my needs. I can do manual cut/paste/delete, but I would prefer to automate, because sometimes camera adds up to 8 folders for one day (not sure about the reason).

Any ideas? Note: there are multiple days photos mixed with multiple folders of single day photos, so for part folders such simple rename works.
Stars
 
Posts: 2
Joined: Wed Oct 17, 2018 1:36 am

Re: How to merge folders with non-duplicating files?

Postby therube » Wed Oct 17, 2018 1:54 am

Renaming Options -> Prevent Duplicates

I didn't test it so I don't know if it works on directories, but give it a shot & see what it does?
therube
 
Posts: 1317
Joined: Mon Jan 18, 2016 6:23 pm

Re: How to merge folders with non-duplicating files?

Postby Stars » Wed Oct 17, 2018 1:56 am

therube wrote:Renaming Options -> Prevent Duplicates

I didn't test it so I don't know if it works on directories, but give it a shot & see what it does?

It creates 2018_0731_1 ; 2018_0731_2 ; 2018_0731_3 and so on. As I mentioned in first post, it does not help, unfortunately.
Stars
 
Posts: 2
Joined: Wed Oct 17, 2018 1:36 am

Re: How to merge folders with non-duplicating files?

Postby dude » Mon Oct 29, 2018 10:25 pm

  • Put this script in the folder where your 105_0731; 106_0731; 107_0731 folers are.
    So, if you have Q:\Photos\105_0731 and Q:\Photos\107_0731, put this script in Q:\Photos
  • If there are also photos of previous years (2017, 2016, ..) in Q:\Photos, move those folders to somewhere else as there is no way of telling which photos are from 2018 and which are from different years.
  • Check the year in the script (currently: set YEAR=2018 )
  • Double-click the script in Explorer.
    (It will only tell you what it will do; it doesn't actualy move the photos)

    If all is OK:
  • Change these lines in the script:
    Code: Select all
       echo if not exist "%NEWFOLDER%\" md "%NEWFOLDER%"
       echo move "%1\*" "%NEWFOLDER%\"

    to:
    Code: Select all
       if not exist "%NEWFOLDER%\" md "%NEWFOLDER%"
       move "%1\*" "%NEWFOLDER%\"
  • Save script
  • Run the script again to move files and folders.
  • Select all 105_0731 -like folders in Explorer
  • Right-click on selection
  • Choose Properties
  • If size = 0 bytes (meaning all folders are empty): remove those folders.


Next year (2019), you don't have to move the 2018_xxxx folders out of the way; those will be skipped.
Just change set YEAR=2018 to: set YEAR=2019 and run he script again.


FolderMerge.cmd
Code: Select all
@echo off
setlocal
pushd "%~dp0"

::______________________________________
::
   set YEAR=2018
::______________________________________
::

   for /d %%x in (???_????) do call :ACTION %%x
   goto :EOF


:ACTION
   set FF=%1
   set NEWFOLDER=%YEAR%_%FF:~-4%
   echo if not exist "%NEWFOLDER%\" md "%NEWFOLDER%"
   echo move "%1\*" "%NEWFOLDER%\"
goto :EOF

dude
 


Return to BRU Support