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.
我想将一些文件从“files”目录移动到根目录。
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.
但我总是得到错误。它无法找到文件,然后CMD停止工作。
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.
但现在它不会将文件移动到父目录。
3 个解决方案
#1
13
/q isn't a valid parameter. /y: Suppresses prompting to confirm overwriting
/ q不是有效参数。 / y:禁止提示确认覆盖
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
另外.. \ txt表示父目录下的目录txt,而不是根目录。根目录将是:\请提及您获得的错误
Try:
尝试:
move files\*.txt \
Edit: Try:
编辑:尝试:
move \files\*.txt \
Edit 2:
编辑2:
move C:\files\*.txt C:\txt
#2
2
Suppose there's a file test.txt
in Root Folder, and want to move it to \TxtFolder
,
假设根文件夹中有一个文件test.txt,并想将其移动到\ TxtFolder,
You can try
你可以试试
move %~dp0\test.txt %~dp0\TxtFolder
.
。
reference answer: relative path in BAT script
参考答案:BAT脚本中的相对路径
#3
0
Try:
尝试:
move "C:\files\*.txt" "C:\txt"
#1
13
/q isn't a valid parameter. /y: Suppresses prompting to confirm overwriting
/ q不是有效参数。 / y:禁止提示确认覆盖
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
另外.. \ txt表示父目录下的目录txt,而不是根目录。根目录将是:\请提及您获得的错误
Try:
尝试:
move files\*.txt \
Edit: Try:
编辑:尝试:
move \files\*.txt \
Edit 2:
编辑2:
move C:\files\*.txt C:\txt
#2
2
Suppose there's a file test.txt
in Root Folder, and want to move it to \TxtFolder
,
假设根文件夹中有一个文件test.txt,并想将其移动到\ TxtFolder,
You can try
你可以试试
move %~dp0\test.txt %~dp0\TxtFolder
.
。
reference answer: relative path in BAT script
参考答案:BAT脚本中的相对路径
#3
0
Try:
尝试:
move "C:\files\*.txt" "C:\txt"