Check if a file exists or not in Windows PowerShell?

后端 未结 7 1543
自闭症患者
自闭症患者 2020-12-03 02:38

I have this script which compares files in two areas of the disk and copies the latest file over the one with the older modified date.

$filestowatch=get-con         


        
相关标签:
7条回答
  • 2020-12-03 03:04

    You can use the Test-Path cmd-let. So something like...

    if(!(Test-Path [oldLocation]) -and !(Test-Path [newLocation]))
    {
        Write-Host "$file doesn't exist in both locations."
    }
    
    0 讨论(0)
提交回复
热议问题