根据小于系统可用的最大修改日期移动文件 [英] move file based on the less than max system modified date available
问题描述
我想根据少于可用的最大系统修改日期进行迁移
I wanted to move based on the less than max system modified date available
Name date Modified
file1 14/05/2018 11:21 AM
file2 14/05/2018 11:41 AM
在这种情况下,我们希望将file1与最大系统修改日期分开.所有剩余的文件都必须移动
In this case we want to move file1 so apart from max system modified date. All remaining files have to move
我已经尝试过以下命令:
I have tried below command:
move /-y "C:\app\folder1*.txt" "C:\app\folder2\"
暂停
尝试了其他步骤
Get-ChildItem -Path "C:\app\folder1\"
Sort-Object LastWriteTime -Descending
Move-Destination t-Object -Skip 1
Move-Item -Destination "C:\app\folder2\" |
我再次尝试得到错误....| C:\ app \ folder1>移动项-目的地"C:\ app \ folder2 \"
i tried again getting error....| C:\app\folder1>Move-Item -Destination "C:\app\folder2\"
移动项"未被识别为内部或外部命令,可操作程序或批处理文件.
'Move-Item' is not recognized as an internal or external command, operable program or batch file.
谢谢
推荐答案
我不知道您是否知道,但是尝试的另一步是powershell.exe
代码而不是cmd.exe
.
I don't know if you were aware, but the other step you tried was powershell.exe
code not cmd.exe
.
类似的事情可能会满足您的要求:
Something similar to this may do what you require:
@Echo Off
Set "dirSrc=C:\App\Folder1"
Set "dirDst=C:\App\Folder2"
Set "extSrc=*.txt"
If Exist "%dirSrc%\%extSrc%" (CD /D "%dirSrc%" 2>Nul || Exit /B
) Else Exit /B
If Not Exist "%dirDst%\" (MD "%dirDst%" 2>Nul || Exit /B)
For /F "Skip=1 Delims=" %%A In ('Dir /B/A-D-H-L-S/O-D/TW "%extSrc%"'
) Do Move /Y "%%A" "%dirDst%">Nul 2>&1
在运行它之前,您需要确保在2
和3
行中指定的目录正确,并且在4
行中的文件掩码正确.
Before you run it, you'll need to make sure that the directories specified in lines 2
and 3
are correct and also the file mask in line 4
is correct.
这篇关于根据小于系统可用的最大修改日期移动文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!