Search code examples
filebatch-filemove

Batch file to move files to another directory


I hope that you can help me with this one. It might have been asked multiple times already (I know that), but for some reason, I just can't have it working.

I want to move some files from the "files" directory to the root directory.

So the files are, for example:

test1.txt test2.txt test3.zip test4.zip test5.exe test6.exe

I want these files to be moved to different directories.

So I'm using something like this:

move files\*.txt ..\txt /q
move files\*.zip ..\zip /q
move files\*.exe ..\exe /q

But I always get errors. It can't find the files and then the CMD stops working.

Thanks.

EDIT:

It's working like this:

move /y .\files\*.txt ..\txt
move /y .\files\*.zip ..\zip
move /y .\files\*.exe ..\exe

But now it won't move the file to the parent directory.


Solution

  • /q isn't a valid parameter. /y: Suppresses prompting to confirm overwriting

    Also ..\txt means directory txt under the parent directory, not the root directory. The root directory would be: \ And please mention the error you get

    Try:

    move files\*.txt \ 
    

    Edit: Try:

    move \files\*.txt \ 
    

    Edit 2:

    move C:\files\*.txt C:\txt