Can't create folder using mkdir
5,962
The /
character is used to separate the different directories, and it fails because the directory 2017
does not yet exist. To create nested directories with the parent directories created automatically, use
mkdir -p 2017/October/10
Author by
Teo Protoulis
Updated on September 18, 2022Comments
-
Teo Protoulis almost 2 years
I want to create a folder following the below procedure:
set folder 2017/October/10 mkdir $folder
But this isn't possible and I get the message:
mkdir: cannot create directory '2017/October/10': No such file or directory
I want to include that in script function! I could really use some help!
EDIT: This just can't happen!
-
Teo Protoulis over 6 yearsSame result. It didn't work.
-
Panther over 6 yearsThat is not a good name, it will cause problems. You can try
mkdir '2017/October/10'
but imho better use a different delineate 2017.October.10 for exame -
wjandrea over 6 yearsI'd recommend ISO-8601 format for naming files and dirs, so in this case:
2017-10-10
-
thomasrutter over 6 yearsForward slashes aren't allowed in file or directory names on any variant of Unix (including Linux). Even if individual filesystems support it (and the main ones don't), the operating system doesn't. I'd recommend dashes instead.
-
-
Teo Protoulis over 6 yearsI want the name of the directory to be 2017/October/10. I don't want to create a folder and then subfolders within it.
-
wjandrea over 6 years@TeoProtoulis You can't do that. (Edit: sorry for the all-caps)
-
Teo Protoulis over 6 years@wjandrea Yes, I figured that out. Thanks anyway!