How to nest folders in Finder based on columns in a spreadsheet

finder

I have an Excel sheet with 2 columns of data (Feeder, Serial Number).

Excel Sheet

I have 2 separate sets of folders on my Mac labeled the same (Feeder, Serial Number).
enter image description here

Within the Serial Number folders, there's tons o' files.

I need to move the Serial number folders into the Feeder folders based on the corresponding order on the Excel sheet.

There are hundreds of feeders and thousands of serial numbers; many serial number folders will go into the same feeder folder.

I'm sure there must be a quick way to accomplish this using scripts but the answers are frustratingly buried in this laptop and unfortunately, not in my head. :-\

Any help appreciated.

Best Answer

  • Export the Excel as a CSV (assuming there are only the two columns you've shown above, otherwise delete other stuff first), with the separator set to ,
  • Open Terminal
  • Run

    while IFS=, read FEEDER SERIAL; do
        mv "/path/to/$SERIAL" "/path/to/$FEEDER/"
    done < "/path/to/CSV"
    

    (Replace the /path/to parts as needed)

PS: This assumes that the serial numbers are unique.