Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 使用带有源和目标的批处理移动txt文件_Batch File - Fatal编程技术网

Batch file 使用带有源和目标的批处理移动txt文件

Batch file 使用带有源和目标的批处理移动txt文件,batch-file,Batch File,好的,我的移动器文件似乎无法正常工作 echo off @For %%G In ("%~dp0.") Do Set "source=%%~fG" @For %%G In ("%~dp0..\09 Add City and Merge") Do Set "target=%%~fG" move "%source%\*.txt" "%target%" 我已尝试移动“%sourc

好的,我的移动器文件似乎无法正常工作

echo off

@For %%G In ("%~dp0.") Do Set "source=%%~fG"
@For %%G In ("%~dp0..\09 Add City and Merge") Do Set "target=%%~fG"

move "%source%\*.txt" "%target%"
我已尝试
移动“%source%”“%target%”

我的批处理文件位于自己的文件夹08 Edit City and State\City and\State中
在文件夹City and State中,我有许多需要移动的txt文件
我一直在处理这个问题,由于某种原因,我无法让它工作
我有许多脚本可以很好地与源和目标设置配合使用
只有我的移动器脚本不起作用

Main Folder
     |08 Edit City and State
            |City
               |City.txt
            |State
               State.txt
     |09 Add City and Merge
谢谢你

我只在有助于任何人了解如何设置移动脚本的情况下才将这些内容发布在这里

我确信这是可行的,但我尽量避免像这些脚本那样设置Dir

伟大的Mofi工作

Command Prompt - Setup
for /F "delims=" %I in ('dir "C:\Main Folder\08 Edit City and State\*.txt" /A-D /B /S 2^>nul') do move "%I" "C:\Main Folder\09 Add City and Merge\"

Batch Script - Setup
for /F "delims=" %%I in ('dir "C:\Main Folder\08 Edit City and State\*.txt" /A-D /B /S 2^>nul') do move "%%I" "C:\Main Folder\09 Add City and Merge\"

Robocopy - Setup
%SystemRoot%\System32\robocopy.exe "C:\Main Folder\08 Edit City and State" "C:\Main Folder\09 Add City and Merge" *.txt /S /MOVE /NDL /NFL /NJH /NJS
Command Prompt - Setup
for /F "delims=" %I in ('dir "C:\Main Folder\08 Edit City and State\*.txt" /A-D /B /S 2^>nul') do move "%I" "C:\Main Folder\09 Add City and Merge\"

Batch Script - Setup
for /F "delims=" %%I in ('dir "C:\Main Folder\08 Edit City and State\*.txt" /A-D /B /S 2^>nul') do move "%%I" "C:\Main Folder\09 Add City and Merge\"

Robocopy - Setup
%SystemRoot%\System32\robocopy.exe "C:\Main Folder\08 Edit City and State" "C:\Main Folder\09 Add City and Merge" *.txt /S /MOVE /NDL /NFL /NJH /NJS