Using my below given script, I simply wanted to cut-paste all the .dat files created today from source to destination, where source is a network path.
@echo off
set datetime=%date:~0,2%-%date:~3,2%-%date:~6,4%_%time:~0,2%-%time:~3,2%
mkdir "D:\data\Backup\%datetime%"
net use L: \\10.xx.xx.xxx\shared\files /persistent:no
set source=L: \\10.xx.xx.xxx\shared\files
forfiles /P "%source%" /M *.dat /D +0 /C "cmd /c move @path D:\data\Backup\%datetime%"
net use L: /delete /y
BUT..its throwing ERROR: The directory name is invalid.
I am not getting why FORFILES
is not accepting my network path as a source.
Please can somebody help me out here ?
I have no issue in using powershell as well.
In PowerShell:
$src = '\\10.xx.xx.xxx\shared\files'
$dst = "D:\Data\Backup\$(Get-Date -f 'yyyyMMdd')"
mkdir $dst
Get-ChildItem $src -File | Where {$_.LastWriteTime -gt (Get-Date).Date} | Copy-Item $dst
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.