OSX Finder drag and copy search results and create sequenced filenames for duplicates

Discussion in 'Mac OS X Lion (10.7)' started by mosscliffe, Mar 4, 2013.

  1. mosscliffe macrumors newbie

    Joined:
    Mar 4, 2013
    #1
    I want to put all my photos in one directory.

    I do a search in Finder for the files. ".jpg"

    I select all the files found and alt-drag them to my new aggregate directory.

    But some of the filenames are duplicated.

    How can I get the operation to automatically add sequence numbers to duplicate filenames, like browsers do, when downloading ?

    Thanks

    OSX Snow Leopard 10.6.8
     
  2. benwiggy macrumors 68020

    Joined:
    Jun 15, 2012
    #2
    Not easily in Snow Leopard. However, in Lion and above, new options are available for merging such selections.
    Can I ask why you want to put ALL your photos in one big folder? Hierarchical structures using folders are more efficient and methodical.
     
  3. mosscliffe thread starter macrumors newbie

    Joined:
    Mar 4, 2013
    #3
    Because they are all in multiple directories accumulated over time (15+ years), with no real structure and sourced from different cameras etc. Copied and backed up over and over again.

    When I have got them all together, then I shall look at the icons and move them to a simple hierarchy.

    I tried finding duplicate file programs, but they always seem to decide which is the original file and I know from the directory structure it was not.

    Thanks for the info.

    If anyone knows a Snow Leopard solution - I would be most grateful to learn it.
     
  4. snorkelman, Mar 4, 2013
    Last edited: Mar 4, 2013

    snorkelman macrumors 6502a

    snorkelman

    Joined:
    Oct 25, 2010
    #4
    http://www.noodlesoft.com/hazel.php

    might do something similar to what you're after

    eg

    setup a folder (PhotoDump) on desktop

    fire up Hazel

    click + symbol near bottom left and add a new folder (PhotoDump)

    [​IMG]


    then + under rules to create a new rule

    [​IMG]

    any jpegs dragged and dropped into that folder will get the renaming applied to add a sequential number to every one between its original name and its .jpg file extension.

    While not exactly what you're looking for (every file will have a sequential number added to its name, not just dupes) it should leave you with a single folder worth of jpegs, each individually named, all duplicate files included.

    Any files that had duplicate filenames will begin with the original duplicate part of their names, so while the sequential number between them may vary wildly they will still be listed next to each other when sorted by filename

    eg assuming you dragged n dropped two copies of DSC001.jpg into the folder with loads of other files dropped in between times:

    DSC001_237.jpg
    DSC001_579.jpg

    it should be SL compatible ..Finder will probably complain you're going to overwrite a file with a duplicate but by time you hit OK and the file goes over to the directory, Hazel should have renamed the dupe so an overwrite wont take place.
     
  5. mosscliffe thread starter macrumors newbie

    Joined:
    Mar 4, 2013
    #5
    That is brilliant.

    Funnily enough, I looked at Hazel last night and decided, it was far too complicated for me.

    But with an explanation like you have given - I shall download it tonight and hopefully have all my images in one folder tomorrow.

    Many thanks
     
  6. mosscliffe, Mar 5, 2013
    Last edited: Mar 5, 2013

    mosscliffe thread starter macrumors newbie

    Joined:
    Mar 4, 2013
    #6
    Bad News

    It sort of worked, but it had problems.

    Because of the number of files involved, when dragging, all you got was the spinning rainbow and it was difficult to know you had selected the right directory.

    Initially it selected all 44,000+ files and attempted to copy them, but gave up at 9,000+. I re-selected the remainder and that gave up at 5,000+. Then the next lot gave up at 250 or so, then 28, then I went to bed.

    It appears that Hazel is not happy with the number of files it is handling or there is some max for sequence number.

    I will have another go setting up 5 dump directories and copying a max of 8,000 into each directory.
     
  7. benwiggy macrumors 68020

    Joined:
    Jun 15, 2012
    #7
    This is of course where Unix shell scripting comes in handy. It would be fairly straightforward to write a script that moves the files, checking for existing names, and renames according to some pattern.
     
  8. mosscliffe thread starter macrumors newbie

    Joined:
    Mar 4, 2013
    #8
    Thanks for the idea

    Unfortunately I have not done UNIX shell scripts for over 20 years and the brain is a bit slow on the uptake now.

    If someone could give me a small amount of guidance - I may be able to work it out.

    Basically it would be

    a 'find *.jpg or *.png' in source directory and all subdirectories
    then check if filename.ext exists in destination
    if it does add a sequence number to basic filename and append extension
    write file to destination

    Basic Questions
    Does the script have to end in .sh and have some reference to usr/bin in the first few lines ?
    Do you need to add execution permission ?
     

Share This Page