Check if a file exists or not in Windows PowerShell?

后端 未结 7 1573
自闭症患者
自闭症患者 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 02:56

    Just to offer the alternative to the Test-Path cmdlet (since nobody mentioned it):

    [System.IO.File]::Exists($path)
    

    Does (almost) the same thing as

    Test-Path $path -PathType Leaf
    

    except no support for wildcard characters

提交回复
热议问题