我想要的是一个批处理文件,它将所有文件从一个文件夹移动到另一个文件夹,并使用视图将其安排为每天运行两次的任务。
我知道整个移动命令等,但似乎每次只能移动一个文件或移动整个文件夹
我需要文件夹保留在那里,但里面的文件要移动
凯尔,干杯
答案1
下一个脚本可能会有帮助:
@ECHO OFF >NUL
SETLOCAL enableextensions
set "folderIn=D:\test\Files In"
set "folderOu=D:\test\Files Out"
set "logFile=%folderOu%\movelog.txt"
set "logToDo=>> "%logFile%" 2>&1"
rem above line causes that moved file names will be logged to file %logFile%
rem unrem next line if you need no log
rem set "logToDo="
set /A "filesInNo=0"
for /f "tokens=*" %%# in ('dir /B "%folderIn%\*.*" 2^>NUL') do set /A "filesInNo+=1"
(
echo === %date% %time% === %filesInNo%
if %filesInNo% GTR 0 (
move /Y "%folderIn%\*.*" "%folderOu%\"
) else (
rem Nothing to copy
)
)%logToDo%
rem next line for debugging purposes only
if not "%*"=="" type "%logFile%"
ENDLOCAL
goto :eof
有关解释请参阅rem
评论和资源(必读):
- (命令参考)Windows CMD 命令行的 AZ 索引
- (其他细节)Windows CMD Shell 命令行语法
- (
%~#
等专题页面)命令行参数(参数) - (
>>
等2>&1
专题页面)重定向