将今天创建的所有文件从网络位置移至本地驱动器 [英] Move all files created today from network location to local drive

查看:79
本文介绍了将今天创建的所有文件从网络位置移至本地驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用下面给出的脚本,我只想将今天创建的所有.dat文件从源剪切到目标位置,其中源是网络路径.

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 ..其抛出ERROR: The directory name is invalid.

BUT..its throwing ERROR: The directory name is invalid.

我不明白为什么FORFILES不接受我的网络路径作为源.

I am not getting why FORFILESis not accepting my network path as a source.

请有人在这里帮助我吗?

Please can somebody help me out here ?

我也没有使用Powershell的问题.

I have no issue in using powershell as well.

推荐答案

在PowerShell中:

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

这篇关于将今天创建的所有文件从网络位置移至本地驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆