Converting .iso file to .img using the convert option of hdiutil

Discussion in 'Mac Basics and Help' started by calvin123, Jan 5, 2017.

  1. calvin123 macrumors newbie

    Joined:
    Jan 5, 2017
    #1
    Keep receiving the following message:
    hdiutil: convert: only a single input file can be specified
    Usage: hdiutil convert -format <format> -o <outfile> [options] <image>
    hdiutil convert -help

    I am entering the following into the terminal, where am I going wrong?

    hdiutil convert -format UDRW -o ~/Users/calvin/Local Documents2/arch2.img ~/Users/calvin/Local Documents1/arch123.iso

    All responses are appreciated.
     
  2. KALLT, Jan 5, 2017
    Last edited: Jan 5, 2017

    KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #2
    You have to escape the spaces in the file path.

    Either do this:
    Code:
    hdiutil convert -format UDRW -o /Users/calvin/Local\ Documents2/arch2.img /Users/calvin/Local\ Documents1/arch123.iso
    Or this:
    Code:
    hdiutil convert -format UDRW -o "/Users/calvin/Local Documents2/arch2.img" "/Users/calvin/Local Documents1/arch123.iso"
     
  3. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #3
    1. An absolute pathname should not start with ~/.
    2. A ~/ must be outside the quotes, or the shell won't expand it.

    Compare the outputs of:
    Code:
    echo ~/
    echo "~/"
     
  4. calvin123, Jan 5, 2017
    Last edited: Jan 5, 2017

    calvin123 thread starter macrumors newbie

    Joined:
    Jan 5, 2017
    #4
    Hi guys thanks for the fast responses, getting rid of the spaces seemed to do it (I think that was the reason or was it something else newbie to Mac).

    This is what I entered for it to work:
    hdiutil convert -format UDRW -o /Users/calvin/LocalDocuments2/arch2.img /Users/calvin/LocalDocuments1/arch123.iso

    If the spaces was the problem could someone please explain why?
     
  5. KALLT, Jan 5, 2017
    Last edited: Jan 5, 2017

    KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #5
    Good catch, I actually did not even pay attention to this once I saw the space, and just copied the path as is.

    Bash interprets spaces as delimiters of parameters. Suppose you only added the first file path to the command, then Bash would have interpreted it was two file paths and would have accepted the command. It obviously would eventually also fail, as the paths are not correct.

    You should get used to dragging and dropping files into Terminal directly or using tab completion. When you start typing a path and press tab once, Terminal will attempt to complete the path for you as far as it can before any disambiguation. You can press tab twice to see how you can branch off in case of multiple possible paths.
     
  6. calvin123 thread starter macrumors newbie

    Joined:
    Jan 5, 2017
    #6
    Ah sweet, so if just for some reason I wanted 2 copies of the .img file and had 2 directories names 1:Local 2:Documents2 and entered the following as my output /Users/calvin/Local Documents2/arch2.img would this have worked?

    Also when in finder is there a shortcut for going up a directory?
    Many thanks for your help!

    Not sure why it has given the green smiley but should be 2: Documents2
     
  7. chrfr macrumors 603

    Joined:
    Jul 11, 2009
    #7
    Spaces were part of the problem but your path was also incorrect:
    Code:
    ~/Users/calvin/Local Documents2/arch2.img
    Ignoring the space for the moment, the ~ in the front of the path indicates the current user's home folder, so what you typed is actually translated as the following by the computer (again ignoring the space for the moment) :
    Code:
    /Users/calvin/Users/calvin/Local Documents2/arch2.img
    You'd either want to use /Users/calvin or the ~ but not both. Using the ~ can have some complications as shown above in post #3. You can never go wrong with using the actual full path instead of ~ for files in your home folder.
    Another helpful tip is that you can enter the command, in this case the
    Code:
    hdiutil convert -format UDRW -o
    and then press space and drag the original file into the terminal window. This will show you the syntax and path the terminal is expecting so that you can enter something that'll be correct for your output file.
     
  8. calvin123, Jan 6, 2017
    Last edited: Jan 6, 2017

    calvin123 thread starter macrumors newbie

    Joined:
    Jan 5, 2017
    #8
    Thank you very much chrtr I think you have cleared it all up for me, makes much more sense now. Is there a useful website containing information like this that you think might be of help?
     
  9. KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #9
    No. ;)

    You have to check the synopsis of the command to see whether it supports this. hdiutil does not:
    Code:
    hdiutil convert image -format format -o outfile
    It expects all of the things that are not within brackets. If you were allowed to specify multiple input files, it would have marked this with an ellipsis, such as this:
    Code:
    hdiutil convert image ... -format format -o outfile
     
  10. calvin123 thread starter macrumors newbie

    Joined:
    Jan 5, 2017
    #10
    Ah awesome thanks for the help KALLT greatly appreciated.
     

Share This Page