PowerShell移动文件类型为.file

3

我有一些没有文件扩展名的文件。如何在powershell中移动它们?

以下是我的文件:

$backupPATH = new-item -ItemType directory C:\Users\user\Desktop\location\$(get-date -f MM-dd-yyyy_HH_mm_ss)
$date = (get-date).AddDays(-60)
get-childitem -Path C:\Users\user\Desktop\test1 *.tsv |
where-object {$_.LastWriteTime -lt $date} |
move-item -destination $backupPATH

以下是移动没有扩展名的文件的脚本,但不确定从哪里开始。
get-childitem -Path C:\Users\user\Desktop\test1 |
where-object {$_.LastWriteTime -lt $date} |
move-item -destination $backupPATH
1个回答

2
只需过滤扩展名为空的文件即可:Extension 属性为空的文件。
get-childitem -Path C:\Users\user\Desktop\test1 |
where-object {$_.LastWriteTime -lt $date -and -not  $_.Extension} |
move-item -destination $backupPATH

这就是 shell 的 威力 :) - MrPaulch
是的!非常顺利地工作了。非常感谢! :) - user3829304

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接