Ошибка в синтаксисе команды mkdir

mkdir is unable to create direcotry

mkdir path/to/dir
The syntax of the command is incorrect.

asked Oct 17, 2018 at 20:44

Anadil's user avatar

Use back slashes, like this:
mkdir pathtodir

answered Oct 17, 2018 at 20:46

Anadil's user avatar

AnadilAnadil

4891 gold badge4 silver badges7 bronze badges

2

I am kind of new to cmd for I am a linux guy. In the code bellow I am trying to find a .mp3 or .mp4 file and save there path to a file and then move the .mp3/.mp4 into the file. I get a syntax error on the mkdir command

ECHO off
pause
mkdir "/Users/media"
pause
cd /Users/
dir *.mp3 >Users/media/output.txt/s
dir *.mp4 >>Users/media/output.txt/s

pause
for /r %%a IN (*.mp3) do (
move /y "%%a" "/Users/media"
)
pause
for /r %%a IN (*.mp4) do (
move /y "%%a" "/Users/media"
)

thanks any help would be appreciated

asked Nov 9, 2015 at 6:14

MathMXC's user avatar

2

Windows supports forward slashes in many scenarios but prefers backslashes. So you should change the appropriate line to

mkdir Usersmedia

If your path contains spaces you have to surround it with quotation marks. In case the users directory does not exist you can add a -p to the command which will have it create the complete hierarchy you specify.
Depending on how you use the batch you might want to add a drive letter to your path and check the errorlevel of the mkdir command.

Read more about mkdir here, this site lists the other available commands too.

As you are coming from Linux I want to mention that bash and others can be installed on Windows too, there even are UNIX «emulations» like Cygwin. There are alternatives to batches, for example Windows scripting host which looks more like regular programming and adds support for vbscript and JavaScript. Or you have a look at powershell.
Both alternatives create (but I am maybe biased) better, more readable and maintainable code. Batches are often a pain to those that follow you and have to understand and change.

answered Nov 9, 2015 at 7:08

Marged's user avatar

MargedMarged

10.5k10 gold badges56 silver badges99 bronze badges

Tong Vang

C:UsersTomodot>mkdir -p spec/features/todo_lists
The syntax of the command is incorrect.

Why is my cmd line saying this?

1 Answer

Nick Fuller

Hi Tong! (I’m assuming) You’re using Windows and Ruby (Oh boy you’re a brave soul!). It certainly is possible, but the few I know whom have tried end up with virtual machines!

The issue it seems is the file path structure. You’re following the lessons on Treehouse (great idea) but they use Apple with OSX which is unix based. You’re using Windows which is DOS based. The directory structure in DOS and OSX are different. DOS uses a backslash «» and unix systems use a forward slash «/». It looks like you’re trying to use a forward slash when you should use a backslash. Furthermore, I’m not sure if windows supports the -p flag (I don’t know enough about DOS).

perhaps try mkdir specfeaturestodo_lists

Пытаюсь выполнить скрипт на nmp

"scripts": {
  ...
  "uglify": "mkdir -p dist/js && uglifyjs src/js/*.js -m -o dist/js/app.js"
}

выдает ошибку

Ошибка в синтаксисе команды.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontendTemplate@0.0.1 uglify: `mkdir -p dist/js && uglifyjs src/js/*.js -m -o dist/js/app.js`
npm ERR! Exit status 1

Если создать папки вручную и выполнить чисто

"uglify": "uglifyjs src/js/*.js -m -o dist/js/app.js"

То выходной файл создается.
В общем я так понял что в винде mkdir -p не поддерживается. =(
Так как тогда настроить проект ?
gulp, и тд пока не хочу использовать так как проект не большой.

When I run

mkdir ../../bin/Release_Linux/Resources

Im getting an error

$ mkdir ../../bin/Release_Linux/Resources
mkdir: cannot create directory ‘../../bin/Release_Linux/Resources’: No such file or directory

Or just

mkdir Release_Linux/Resources
mkdir: cannot create directory ‘Release_Linux/Resources’: No such file or directory

muru's user avatar

muru

192k52 gold badges468 silver badges719 bronze badges

asked Nov 28, 2018 at 15:41

Slobodan Vidovic's user avatar

1

Probably a parent directory in the path does not exist.

You can try with

mkdir -p /path-to-directory/directory-name

See man mkdir

   -p, --parents
          no error if existing, make parent directories as needed

If you get a permission denied error, you have not permissions to create a directory in the specified path.

Check if you can get around the problem by modifying the group membership or ownership, so that you get the permission needed for the whole directory path involved.

Otherwise you need elevated permissions, so try with sudo

sudo mkdir -p /path-to-directory/directory-name

answered Nov 28, 2018 at 15:46

sudodus's user avatar

6

sudodus’s answer appropriately addresses how to create all directories along the given path. Alternative way would be via Python. This is especially useful if you’re developing software for Ubuntu in Python and need such functionality. Calling mkdir as external command would add overhead of additional process and extra forking which would waste resources. Luckily Python’s standard library, specifically os module has makedirs() function:

$ python3 -c 'import os,sys;os.makedirs(sys.argv[1])' test_1/test2/test_3
$ tree test_1
test_1
└── test2
    └── test_3

2 directories, 0 files

Note that such behavior also can be achieved in Perl, which is another scripting language that comes by default with Ubuntu.

answered Nov 29, 2018 at 8:41

Sergiy Kolodyazhnyy's user avatar

I had this when the current directory literally didn’t exist anymore.

I was in directory temp:

mark@mark:~/PycharmProjects/temp$ mkdir foo
mkdir: cannot create directory ‘foo’: No such file or directory

I saw the light when the current directory was empty (not even the hidden . and .. existed):

mark@mark:~/PycharmProjects/temp$ ll
total 0

One directory up temp does exist, but it is another directory with the same name. PyCharm must have deleted and recreated the project directory when I was rolling back too much changes and undoing the rollback.

mark@mark:~/PycharmProjects/temp$ cd ..
mark@mark:~/PycharmProjects$ ll
total 12
drwxrwxr-x  3 mark mark 4096 Nov  2 14:26 ./
drwxr-xr-x 40 mark mark 4096 Nov  2 14:50 ../
drwxrwxr-x  3 mark mark 4096 Nov  2 14:42 temp/
mark@mark:~/PycharmProjects$ cd temp
mark@mark:~/PycharmProjects$ mkdir foo
mark@mark:~/PycharmProjects$ 

Melebius's user avatar

Melebius

11k8 gold badges50 silver badges76 bronze badges

answered Nov 2, 2020 at 13:58

Mark Jeronimus's user avatar

Mark JeronimusMark Jeronimus

4231 gold badge4 silver badges21 bronze badges

1

Понравилась статья? Поделить с друзьями:
  • Ошибка в синтаксисе команды cmd что это
  • Ошибка в синтаксисе команды clean all
  • Ошибка в симс отсутствует файл
  • Ошибка в симс 4 память не может быть
  • Ошибка в симс 4 wickedwhims exception