[Solved] How kan Send a file with mail If there is the new file(today’s date) in the directory? [closed]


I wrote you simple script that will get all the files in the folder and will check if there is any file created today as you ask. I assume you know what to do with the files you find.

## Your folder Path
$folderpath = "C:\temp"
## Getting today date (only date with no time)
$date = (get-date).Date

## Checking if the path is reachable 
if (Test-Path $folderpath)
   {
    ## getting all the files in the folder
    $files = Get-ChildItem $folderpath
    ## Running a for each loop for all the files
    foreach ($file in $files)
          {
           ## checking if the file creation time is today
           if(((Get-Item $file).CreationTime) -gt $date)
             {
               ## do what you want here
             }
          }
    }   

Hope it will help you, let me know if you need anything else.

0

solved How kan Send a file with mail If there is the new file(today’s date) in the directory? [closed]