How do I move a lot of binary files in several subfolders?

Discussion in 'Mac Programming' started by Kalixa, Oct 17, 2007.

  1. Kalixa macrumors member

    Jun 25, 2007
    Hello. I have a lot of binary linux files which I compiled back in the time I used linux. They are organized into several subfolders which have both the source code, a backup of the source code and the binary file. Can someone please help me to find out how to move/or delete these files, without having to drag and drop each individual file. (That would take quite a long time).
  2. toddburch macrumors 6502a

    Dec 4, 2006
    Katy, Texas
    Got a naming convention? Is there a tree structure that can be followed by a script? Got a list of all the files or paths you want if they are spread across tarnation?

    Not enough information to propose a solution.

  3. mkrishnan Moderator emeritus


    Jan 9, 2004
    Grand Rapids, MI, USA
    Yeah, I don't understand based on the information either. You can create a zip or tar file and then add files to it by directory. Or else, if you're at least mildly organized, you can just copy the entire uplevel folder onto your backup device. But since you're asking the question, I'm guessing that's not an option for some reason, but I don't know why?
  4. ChrisA macrumors G4

    Jan 5, 2006
    Redondo Beach, California
    If there is a pattern to the names you can use "find". See "man find". It will apply a command to a set of files that match a pattern. The pattern is very general and can be things like "executable files with date before X and with "s" as the third letter in the name and all are under directory Y. Find can be very usfull when you have many, many files that all need the same thing done to them.
  5. Mumford macrumors regular


    Oct 8, 2006
    Altadena, CA
    If you're not afraid of using the terminal, this is easy. The 'file' command will give you info about a file. For a linux binary I just copied to my Mac as a test it reports:

    bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
    for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped
    So theoretically all you need to do is run 'file' on every file in that tree, grep for linux in the results and rm them. You can use the command below for that. Replace the '.' at the start with the start of the directory tree that has all these files:

    $ rm `find . -type f -exec file '{}' \; | grep -i linux | awk -F: '{print $1}'`
    If that's too scary, just run this:

    $ find . -type f -exec file '{}' \; | grep -i linux | awk -F: '{print $1}'
    to see what linux files it finds without actually removing them.

Share This Page