24

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.

user2077474
  • 353
  • 1
  • 6
  • 15

3 Answers3

21

/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
Jerry
  • 4,258
  • 3
  • 31
  • 58
  • Yes, sorry, I already fixed that, I'm using /y now. There is no error, it just can't find the files but they do exist in the "files" directory. And yes, I want to move them to the folders on the parent directory. – user2077474 Apr 26 '13 at 20:28
  • Try: move \files\ *.txt \ [I updated the reply, since it doesn't display properly here] – Jerry Apr 26 '13 at 20:31
  • No, it keeps saying that I can't find the files. – user2077474 Apr 26 '13 at 20:39
  • try the full path: move C:\files\ *.txt C:\ , make sure it contains files *.txt and that they aren't hidden. – Jerry Apr 26 '13 at 20:39
  • As I mentioned before: ..\txt isn't the parent directory. It is txt directory under the parent directory. Is this what you need? Is there txt directory under parent directory? – Jerry Apr 26 '13 at 20:52
  • Haha, yes, that is what I need. Sorry for the bad English, its not always like that, it's just that I'm doing so many things at the moment. – user2077474 Apr 26 '13 at 20:54
  • I will, could you just help me with the last step? I need to move .txt files to the "txt" folder on the parent directory. – user2077474 Apr 26 '13 at 21:01
  • This should do it: move /y .\files\*.txt \txt But make sure txt folder already exists – Jerry Apr 26 '13 at 21:03
  • Thanks, that did work. Is there anyway that I can move the files to the txt folder on the parent directory without specifing the full directory? – user2077474 Apr 26 '13 at 21:15
  • ..\txt should work. But this means you are already in the files folder(since the parent is the root). – Jerry Apr 26 '13 at 21:17
  • For some reason ..\txt does not work. And for the upvote I need 15 reputation, sorry. – user2077474 Apr 26 '13 at 21:21
  • OK. Just make sure about the current directory. It must be files. – Jerry Apr 26 '13 at 21:22
  • Haha, thanks. I did a cd files and now its working perfectly fine. – user2077474 Apr 26 '13 at 21:26
3

Suppose there's a file test.txt in Root Folder, and want to move it to \TxtFolder,

You can try

move %~dp0\test.txt %~dp0\TxtFolder

.

reference answer: relative path in BAT script

yu yang Jian
  • 6,680
  • 7
  • 55
  • 80
1

Try:

move "C:\files\*.txt" "C:\txt"
Mohammad Usman
  • 37,952
  • 20
  • 92
  • 95
lorfo
  • 11
  • 1