what does $file mean in Powershell Examples?

In so many examples I see online I see the use of “$file” over and over again.

Is this a reference to the literal path of your choosing which is why they state it this way?


For example with regard to the following code:

function WaitForFile($File) {
while(!(Test-Path $File)) {
Start-Sleep -s 10;

does the $File refer to a user definable path such as C:\Temp?


would really like some clarification here.

$file is just another variable used by the author of the articles you have seen. Not all the examples comes with 100% code.

Thanks for the response kvprasoon.

Any good sample code for polling for folder changes such as new files arriving in the folder and then moving those files elsewhere?

Polling can be accomplished with a scheduled task. Get-ChildItem can be used to get files and Move-Item can be leveraged to move the file. A simple script can be created when executed to perform the logic you specified above. There are other more advanced options like FileSystemWatcher that can monitor a directory and immediately move a file based on a create event:


Annnddd you started an entirely different thread for this:


This question is already started as a different thread.