What Type of File Is It?

Discussion in 'macOS' started by aaphid, Aug 3, 2009.

  1. aaphid macrumors member

    Joined:
    Aug 3, 2009
    #1
    I have a file that I don't know how to open. It's 2GB and from what I remember it was either a .zip or .dmg file. However some time ago when I made it I also removed the last 3 characters from the name and renamed it .mov. This changed the way that finder dealt with it. Now I would like to open it but when I change the suffix to either of the above they aren't recognised making me wonder if either the file is corrupt or maybe it's not a zip or dmg.

    How can I tell what the file is? I've gone into terminal and queried it with the "file" command but it just tells me that it's data.

    Any ideas?
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    You could try opening it with VLC. It supports a number of movie formats and may be able to determine if it is one of those. It's also possible the file has become corrupt with trying to open it in various applications. If you're comfortable with the command line I may have another option to try.
     
  3. aaphid thread starter macrumors member

    Joined:
    Aug 3, 2009
    #3
    I'm pretty new to using command line but willing to give it a shot.

    What do you suggest?
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    Some times there is meta information about a file stored at the beginning of the file and it's usually in ascii format so it's human readable even if the rest of the file is binary. Using the head command we can take a look at the first few lines of the file to see if there's any information to give you a clue as to its origin.

    Code:
    head -1 path/to/file
    Will show the first line of the file.

    Below is an example piece of output from using the head command on a MP4 video files that I had laying around.
    I highlighted parts that give clues that it is a video file. I'm at a Windows machine (using cygwin for unix) so can't check what a DMG file would look like.
     
  5. amiradou macrumors newbie

    Joined:
    Aug 4, 2009
    #5
    Re: what type of File is it?

    doing the command head like previously suggested is only viable if the Magic identifier is actually readable. If you're looking at a Macho binary for example that method won't work.

    However since MacOS X has has a unix shell, simply open the command line and type:

    file filename

    in the directory of the file ( or file filepath anywhere ) and you will get the type of file and other useful information about it.

    For example doing:
    > file Adium
    Adium: Mach-0 fat file with 2 architectures
    >
     
  6. aaphid thread starter macrumors member

    Joined:
    Aug 3, 2009
    #6
    Code:
    head -1 path/to/file
    Will show the first line of the file.

    Here is what I get:-

    Desktop aa$ head -1 path/to/file Test.zip
    head: path/to/file: No such file or directory
    ==> Test.zip <==
    smhead(13641) malloc: *** mmap(size=2397048832) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    a-as-mac-mini:Desktop aa$ sm
     
  7. r.j.s Moderator emeritus

    r.j.s

    Joined:
    Mar 7, 2007
    Location:
    Texas
    #7
    You need to replace path/to/file with the file's path ... just drag the file to the Terminal window.
     
  8. Amdahl macrumors 65816

    Joined:
    Jul 28, 2004
    #8
    The answer you were looking for...

    Use the file command.

    $ file journey-lights-live.mp3
    journey-lights-live.mp3: MP3 file with ID3 version 2.2.0 tag

    edit: I see amiradou also suggested this, and I guess was ignored.
     
  9. aaphid thread starter macrumors member

    Joined:
    Aug 3, 2009
    #9
    Thanks Amdahl but I didn't ignore it. I actually mentioned in my opening post that this was already one of the things that I have tried. The "file" command just returns one word "data".
     
  10. aaphid thread starter macrumors member

    Joined:
    Aug 3, 2009
    #10
    Aaaahhhh, I see!
    Here's what I get...

    Desktop aa$ head -1 /Users/aa/Desktop/Test.zip
    head(2070) malloc: *** mmap(size=2397048832) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
     

Share This Page