批处理文件将.txt移动到另一个文件夹

时间:2022-04-25 02:23:04

i want ot create a batch files but i have not much experience in this.. is anyone can help me? i want to create a batch file which is the main function is to move some .txt files from a folder (A) to another folder (B)?
but those .txt that going move to other file must base by a condition and the condition is when i trigger the batch file i need to know the trigger time or current time and compare the created date and time of .txt file and it must 3 minutes and 3 second ago..
base by this condition i only do the cut and paste from folder A to B
is it doable or anyone can provide me a link so i can refer to it..
thank you very much.

我想要创建一个批处理文件,但我没有太多的经验...是谁都可以帮助我?我想创建一个批处理文件,主要功能是将一些.txt文件从文件夹(A)移动到另一个文件夹(B)?但那些移动到其他文件的.txt必须以条件为基础,条件是当我触发批处理文件时我需要知道触发时间或当前时间并比较.txt文件的创建日期和时间它必须3分钟和3秒前..基于这种情况我只做剪切和粘贴从文件夹A到B是可行的或任何人都可以提供给我一个链接所以我可以参考它..非常感谢你。

1 个解决方案

#1


0  

Yes this is do able. You need to look at robocopy and it's switches, this should see you right. Just type robocopy /? in cmd and make a note of all the switches you need as there are a lot! There will be other ways of doing this with the if statement but I'm not entirely sure about the timestamp issue. Maybe something like this:

是的,这是可以的。你需要看看robocopy和它的开关,这应该是你看对了。只需键入robocopy /?在cmd中记下你需要的所有开关,因为有很多!使用if语句还有其他方法可以做到这一点,但我不完全确定时间戳问题。也许是这样的:

if %Afiletimestamp% < %Bfiletimestamp% xcopy %Afilepath% %Bfilepath% /y

if%Afiletimestamp%<%Bfiletimestamp%xcopy%Afilepath %% Bfilepath%/ y

I'm not sure how to aquire the first 2 variables though, maybe someone else can add to this?

我不知道如何获取前两个变量,也许其他人可以添加到这个?

#1


0  

Yes this is do able. You need to look at robocopy and it's switches, this should see you right. Just type robocopy /? in cmd and make a note of all the switches you need as there are a lot! There will be other ways of doing this with the if statement but I'm not entirely sure about the timestamp issue. Maybe something like this:

是的,这是可以的。你需要看看robocopy和它的开关,这应该是你看对了。只需键入robocopy /?在cmd中记下你需要的所有开关,因为有很多!使用if语句还有其他方法可以做到这一点,但我不完全确定时间戳问题。也许是这样的:

if %Afiletimestamp% < %Bfiletimestamp% xcopy %Afilepath% %Bfilepath% /y

if%Afiletimestamp%<%Bfiletimestamp%xcopy%Afilepath %% Bfilepath%/ y

I'm not sure how to aquire the first 2 variables though, maybe someone else can add to this?

我不知道如何获取前两个变量,也许其他人可以添加到这个?