简体   繁体   English

Windows批处理文件:使用UnixUtils find命令将X分钟之前的文件移动到其他目录

[英]Windows batch file: move files older than X minutes to a different directory using UnixUtils find command

I found the unixutils for Windows and am trying to use the find command to move files older than 30 minutes to a different directory. 我找到了适用于Windows的unixutils,并尝试使用find命令将30分钟以上的文件移动到另一个目录。

I have tried all of the following (also with \\ at the end of SourceDir and/or TargetDir) but get various errors that I'm pretty sure are due to unix using / to delimit directories and Windows using \\ to delimit directories: 我已经尝试了以下所有方法(在SourceDir和/或TargetDir的末尾也用\\进行了尝试),但是我敢肯定是由于使用/来分隔目录的unix和使用\\来分隔目录的Windows导致的各种错误:

find C:\SourceDir -name * -mmin +30 -type f -exec "move {} C:\TargetDir" ;
find C:\SourceDir -name * -mmin +30 -type f -exec "move {} C:\TargetDir" +
find C:\SourceDir -name * -mmin +30 -type f -execdir "move {} C:\TargetDir" ;
find C:\SourceDir -name * -mmin +30 -type f -execdir "move {} C:\TargetDir" +

Has anybody got this to work? 有人有这个工作吗?

I'm also not tied to using this utility - it just seemed like it would be easy to do. 我也不受使用此实用程序的束缚-似乎很容易做到。 I do have to do it via command line, though, as part of a scheduled job, and would very much prefer not to have to install any software. 不过,作为计划作业的一部分,我确实必须通过命令行来执行此操作,并且非常希望不必安装任何软件。 Copying standalone single file utilities is acceptable, though. 但是,可以复制独立的单个文件实用程序。

I believe Windows Powershell is available to me, as well. 我相信我也可以使用Windows Powershell。

Thanks! 谢谢!

I found somebody who helped me with Windows Powershell. 我找到了帮助Windows Powershell的人。 I thought I'd provide an update here in case it helps somebody else later. 我以为我会在这里提供更新,以防日后对他人有所帮助。

The following Powershell command does the same thing: 以下Powershell命令执行相同的操作:

get-childitem -Path "C:\SourceDir" -recurse | where-object {$_.LastWriteTime -le (get-date).AddMinutes(-30)} | move-item -destination "C:\TargetDir" -force

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows 批处理文件删除超过 X 天的文本文件 - Windows Batch file to delete text files older than X days Windows 批处理文件删除早于 X 天的文件,但保留一分钟的 X 文件 - Windows batch file delete files older than X days but leave a min of X files 删除早于x天的目录,使用Windows Batch排除1个目录 - Remove directory older than x days exclude 1 directory using Windows Batch Windows批处理文件:移动超过10天的文件和不带特定字符串的文件名 - Windows batch file: move files that older than 10 days and the filename without a specific string 如何在目录中查找早于 X 时间的文件 - How to find files older than X time in a directory 在Windows中使用批处理文件删除x天数之前的文件 - Deleting a file that is older than x number of days using a batch file in Windows 如果所有文件都超过3天,则批量文件删除目录中的子文件夹 - Batch file to delete subfolders in directory if all files is older than 3 days 批处理文件将超过30分钟的文件从一个文件夹复制到另一个文件夹 - batch file to copy files older than 30 minutes from one folder to another 批处理文件以递归方式查找名为特定名称的文件并移至目录 - Batch file to recursively find files named a specific name and move to a directory 批处理脚本可将文件从scource移到目标文件夹,以保存30天以上的文件 - Batch script to move file from scource to destination folder for files older than 30 day
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM