0

I have a question regarding windows command prompt. I tried to create a cmd file containing simple commands for the use of creating a folder named after the current date , have it create some files and finaly move the folder to a diffrent location. For some reasons the last part is not working right. Here is my code

cd Desktop
mkdir "%DATE%"
cd "%DATE%"
echo new > index.html
echo new > main.js
echo new > style.css 

//move "%DATE%" MeineProjekte <---- thats the problem. Hope someone could help me on this. And if you have any better ways of displaying this code I would appreciate this aswell

I tried to google for a solution and had not mutch luck.

JoeBanana
  • 3
  • 3

2 Answers2

0

After using CD command, you changed the directory. If your MeineProjekte folder is not located inside the %DATE% folder, you can not move %DATE% there.

I assume that you should use cd .. after echo commands. Something like this:

cd Desktop
mkdir "%DATE%"
cd "%DATE%"
echo new > index.html
echo new > main.js
echo new > style.css
cd ..
move "%DATE%" MeineProjekte

It will work only if MeineProjekte is in the scope. If not, you should specify the absolute path to this folder (e.g. C:\MeineProjekte if it is on your C disk).

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
fever
  • 18
  • 4
0

I believe your computer does not know if you're talking about a destination file or directory.

You might try the following:

move "%DATE%"\ MeineProjekte

(The backslash says clearly that %DATE% is a directory.)

Dominique
  • 16,450
  • 15
  • 56
  • 112