1

I have a lot of files (music, pictures, documents) on an external hard drive that I want to copy into the respective folders on OS-X. I would like to automate the copying process and put all .bmp, .jpg and .jpeg into the pictures folder on OS-X, .mp3 into music and so on for all the different file types.

How can I automate this and what software could I use?

  • How are the files organized on the drive? Why is just selecting them in Finder and moving them to the target folders not an option? – nohillside Oct 5 '14 at 14:03
  • They are in various different folders, on a 600GB harddrive. It's a badly maintained backup harddrive, with no apparent organization whatsoever. – jjack Oct 5 '14 at 14:49
0

One option would be to run the following script in Terminal

#!/bin/bash

find /Volumes/NAME_OF_EXTERNAL_DRIVE -type f -print | while read f; do
    case "$f" in
       *.jpg) cp "$f" "~/Pictures/${f##.*/}"
              ;;
       *.mp3) cp "$f" "~/Music/${f##.*/}"
              ;;
       *) echo "Don't know how to handle '$f'"
          ;;
     esac
done

Add lines for additional suffixes and target folders as needed (and also keep in mind that .jpg is not the same as .JPG).

  • Do you happen to know if there is an app that can do this sort of operation? I'd have to get into AppleScript. – jjack Oct 5 '14 at 15:12
  • That's shell scripting actually. Let's see if whether others have ideas as well. – nohillside Oct 5 '14 at 15:22
  • 1
    It's Unix and not AppleScript? I'll have a look at it then. – jjack Oct 5 '14 at 15:38
  • Also note JPEG and jpeg . is also a valid extension that may be used by a file – markhunte Oct 5 '14 at 16:22

You must log in to answer this question.

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