Bat file how to create?

Hello everyone, who knows how to create a bat file, so that folders and files in them are created by clicking on it, for example, I need to work in all code,

1 Like

Begin here
How to create a .bat file

Of course I don’t understand this answer.

A bat file is just a text file with some command line instructions in it, isn’t it? You could use whatever functions your chosen programming language provides to write the text into the file, and give it the appropriate name.

Do you know what you need to put in the batch file?

(I’m presuming a .bat file is still the same as it used to be, back in the days of autoexec.bat - I apologise if there’s some fancy new thing that uses an old name just to be confusing. )

I want to register in this file, for example, 5 folders in these folders, files, so that they would be created by clicking on the bat file.

Assuming you’re using Windows, mkdir is the command to create a directory.

Does it specifically need to be a batch file? Couldn’t you just have a web page which does the same thing?

Not sure this is in the correct section of the forum as it’s nothing to do with databases, but I’m also not sure where it would be better. Server config, perhaps?

I just didn’t find in which section to ask this question, it doesn’t apply to the database, it doesn’t matter sorry

No apology necessary, I was just thinking that you might get more response if the question was in a different section, but I don’t know which one.

Just so happens I just did a couple batch files to create folders. Here are the Windows and Linux versions. In Windows name the file with a .bat extension. In Linux, .sh extension and give the file executable permissions. This is what the code looks like:

Linux

Windows

how to create files?

Do you want to create them from a program / script, or just create them manually?

For the former, just look at whatever instructions your programming language has for creating and manipulating text files, that’s all a batch file is. I don’t know what language you use, so can’t be any more detailed than that.

For the latter, just use a text editor like notepad.

I want to create manually, for example, I figured out how to create a file in the root, but I can’t figure out how to create a file in a folder, for example, the styles file was created in the styles folder

Is the problem that you don’t know how to store the batch file in a folder, or that you don’t know how to have the batch file make folders within a folder? The former is surely just “save as” from your editor, and the latter is shown in the example by @benanamen above.

@echo.>C:\Users\user\Desktop\bat\index.php
it does it in root and i need to create files in javascript styles folders

I can’t see how that command line would create a file in root. But do you mean actual root (c:) or do you mean web root, the virtual root for your site? What happens if you specify the full physical path of your “javascript styles folders” in your echo statement? Are you calling it from PHP code running on a web server, or somewhere else?

At the root of the bat folder, for example, I want all folders and files to be created using a bat file, I can create a folder - mkdir img, I can also create an index.php file in the bat folder - @echo.>C:\Users\user\ Desktop\bat\index.php, but I don’t know how to create a batch file in a folder, there are other folders like javascript styles, how to create files in them?

I must be missing something. If you can create a file in the bat folder, why can’t you create one in any other folder?

echo .> c:\users\user\desktop\bat\in\this\folder\index.php
echo .> c:\users\user\desktop\bat\or\this\one\index.php
echo .> c:\users\user\desktop\javascript\styles\index.php

as long as you create the folders first.

I don’t know why files in folders are not created, but your code didn’t work either, I think even if my code for creating a file in the root of the bat folder is not entirely correct, since the bat file will no longer work, if the folder name is different, it turns out we can create universally only folders but not files.
mkdir img

mkdir js

mkdir css
here is my code working, nothing else works

Are you trying to create empty files or files with content?