Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

batch files folder and text file creation

Tags:

batch-file

I am new to batch files and i want to create a batch file that will

  1. create a folder on the desktop
  2. then add a text file to that folder
  3. and then move the folder to another folder on the desktop

Here is what i have so far:

ECHO off
ECHO CREATING NEW DIRECTORY AND FILE....
md "C:\Users\Paul\Desktop\System software"
echo.>"C:\Users\Paul\Desktop\systemsoftware.txt"
MOVE  "C:\Users\Paul\Desktop\System software" "C:\Users\Paul\Desktop\desktop\systemsoftware.txt"
ECHO Complete
PAUSE

This creates two folders but places both on the desktop and not in a single folder.

like image 334
sharkey Avatar asked Dec 05 '25 05:12

sharkey


1 Answers

Following the required behaviour you described the following will do:

ECHO off
ECHO CREATING NEW DIRECTORY AND FILE....
md "C:\Users\Paul\Desktop\System software"
echo.>"C:\Users\Paul\Desktop\System software\systemsoftware.txt"
MOVE  "C:\Users\Paul\Desktop\System software" C:\Users\Paul\Desktop\desktop\System software 2"
ECHO Complete
PAUSE

You have

  1. created a directory
  2. but then created a file outside of this directory
  3. moved the directory you have created to a directory named exactly the same as the file you have created in step 2.

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!