What I'm trying to do is create a number of folders in the "~/Labs/lab4a/" location (~/Labs/lab4a/ already exists).
Say I want folder1, folder2, folder3 all in the lab4a folder.
This isn't about making nested folders all at one go using the mkdir -p command or going in to lab4a and just making multiple folders at one go. I'm wondering is there a faster way using mkdir to create multiple folders in the same location using relative path.
i.e prompt~/: mkdir Labs/lab4a/folder1 folder2 folder3 To create all those folders in lab4a at once.
Absolute and relative paths in script tools You can also set this option by right-clicking the script tool, clicking Properties, then clicking the General tab. At the bottom of the dialog box, check Store relative path names (instead of absolute paths).
To change directories using absolute pathnames, type cd /directory/directory; to change directories using relative pathnames, type cd directory to move one directory below, cd directory/directory to move two directories below, etc.; to jump from anywhere on the filesystem to your login directory, type cd; to change to ...
Move or Copy Files in Subfolders to a Single Folder. 1 Open a Command Prompt window. 2 Run the following commands, one by one and press ENTER after each line: md "d:\all snaps" cd /d "d:\vacation snaps\2016" for /r %d in (*) do copy "%d" ...
The second method for creating multiple folders requires using the Batch (BAT) file. First you create a root folder in which you want your other folders to appear. Once done, create a text file in root folder and enter the md command in following way.
Next, type in the command "cd" (which stands for "change directory") and specify the path to the folder where you want to create more subfolders. Here's an example: Execute the command by pressing the Enter key. Set Up a New Folder: To set up new folders using command prompt, use the command "md" (stands for "make directory").
With this command you can create one or several folders. To create a separate folder for each month, you can follow the following format: When you press the Enter key, you won't see anything just yet. However, after you add the "dir" command and press Enter, the command prompt window will display the created folders.
In Bash and other shells that support it, you can do
mkdir ~/Labs/lab4a/folder{1..3}
or
mkdir ~/Labs/lab4a/folder{1,2,3}
Other options:
mkdir $(seq -f "$HOME/Labs/lab4a/folder%03g" 3) mkdir $(printf "$HOME/Labs/lab4a/folder%03g " {0..3})
Which will give you leading zeros which make sorting easier.
This will do the same thing in Bash 4:
mkdir ~/Labs/lab4a/folder{001..3}
Use shell expansion :
mkdir Labs/lab4a/{folder1,myfolder,foofolder}
That such an underestimated possibility :)
my2c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With