windowsaliasmovefile

Windows Command Prompt, how to move folder?


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.


Solution

  • 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).