0

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.

1 Answer 1

1
  • 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.

6
  • I thought this worked at first but it appears to only have worked for the first 10 or so serial numbers and then stopped for some reason?
    – bartc30
    Sep 21, 2015 at 14:37
  • Damn, I thought this worked at first but it appears to only have worked for the first 10 or so serial numbers and then stopped for some reason? All serial numbers are unique. This is what my command looks like: while IFS=, read FEEDER SERIAL; do mv "/Users/bartc/Documents/$SERIAL" "/Users/bartc/Documents/$FEEDER/“ done < "/Users/bartc/Documents/WAVEFORMS.csv" My .csv looks like: 101131,RE11150077 Thoughts? Thx
    – bartc30
    Sep 21, 2015 at 14:46
  • Correction, the 10 I thought worked were already done previous so it doesn't appear to have worked but with no error?
    – bartc30
    Sep 21, 2015 at 14:56
  • Can you add a few lines of your CSV to the question? Also, if you are entering the command on one line in Terminal there needs to be a ; and a space character before done.
    – nohillside
    Sep 21, 2015 at 15:00
  • 1
    Patrix - Issue solved! It was in the way the .csv was formatted. It didn't like the "Classic Mac (CR) Line Break type. I saved it again as Unix (LF) and it ran through perfectly. Many thanks for all your help, you saved me a ton of time. Regards, Bart
    – bartc30
    Sep 21, 2015 at 18:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .