I'm trying to make multiple folders at once but when I press enter it says: mkdir: i/like: No such file or directory.

I do this mkdir i/like/icecream

I think I have the latest version of python. Any help? Ty.

  • 5
    The Unix man pages are a valuable resource, although sometimes hard to read. Try man mkdir :-) – nohillside Jul 23 at 4:37
  • Im trying to learn how to use pushd and popd while reading this book: "Learn Python 3 the Hard Way" by Addison Wesley (2017). It tells me this: cd temp mkdir i/like/icecream pushd i/like/icecream ~/temp/i/like/icecream ~/temp popd ~/temp pwd ~/temp pushd i/like and so on... but I get stuck in mkdir i/like/icecream. It works if i enter mkdir i like icecream, but when I enter pushd it says ~/temp/i/ ~/temp only and it should say ~/temp/i/like/icecream ~/temp – Urayoán Rodz Rivera Jul 23 at 17:34
  • 2
    pushd/popd are used for navigation within the directory structure, not for creating directories :-) – nohillside Jul 23 at 17:36

The switch -p allows deep folder creation along a path

mkdir -p  i/like/icecream/too

You don’t need python for this, unless it reminds you of “p” instead of the pattern passed in to create the full path prefix.

  • 2
    At least under Linux the long format of -p is —parents, so it would be “parents” rather than “path”. – Phoenix Jul 23 at 6:14
  • 1
    @Phoenix BSD: A mkdir command appeared in Version 1 AT&T UNIX. BSD January 25, 1994. My guess is linux reimplemented this or took from GNU, but being inclusive seemed the thing to do. I appreciate your comment here - it made the answer better Sorry for making it sound like you didn't know the score. – bmike Jul 23 at 11:41
  • 2
    @Phoenix It does't give a name to the -p option, probably because there is no long form (ss64.com/osx/mkdir.html). – nohillside Jul 23 at 12:19
  • 1
    Ah, that makes sense then. BSD leaves it open for interpretation. Thanks for the insight. – Phoenix Jul 23 at 14:29
  • 3
    @Phoenix, macOS is not Linux, so what's applicable there is not relevant here! The macOS mkdir manpage states, "−p Create intermediate directories as required. If this option is not specified, the full path prefix of each operand must already exist.", so the use of the term path is just fine! – user3439894 Jul 23 at 15:05

You must log in to answer this question.

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