sharkey
sharkey

Reputation: 33

batch files folder and text file creation

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.

Upvotes: 3

Views: 119

Answers (1)

user1064248
user1064248

Reputation:

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.

Upvotes: 2

Related Questions