title: Searching for files whose names partially match strings in a variable
body: <p>First time poster. I'm seeking some help, since I very rarely dabble in scripting and only very at a very basic level. </p>
  
  <p>I got asked to write a script that searches each word from a list in txt in a backup files folder. The names of the files doesn't exactly match what's in the list and there's three different patterns to match. So in case the backup file isn't there, it's supposed to generate another txt file with the missing ones.</p>
  
  <p>So I wrote this very basic .bat script.</p>
  
  <pre><code>@echo off
  
  del missing backups.txt
  
  FOR /F %%i IN (list.txt) do (@echo %%i
  
  IF NOT EXIST D:\Backups\*XmlConf**%%i* (echo %%i &gt;&gt; missing backups.txt XML)
  
  IF NOT EXIST D:\Backups\*user**%%i* (echo %%i &gt;&gt; missing backups.txt USERS)
  
  IF NOT EXIST D:\Backups\*IVS**%%i* (echo %%i &gt;&gt; missing backups.txt CONFIGURACION)
  )
  </code></pre>
  
  <p>This works pretty well. The problem is I need to add a condition: the files are supposed to have been created in the last 24 hours. This is where I got into trouble. Since this seems to have many complications in bat, I tried my hand at Powershell for the first time.</p>
  
  <p>This is where I'm currently at, after many modifications:</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$list = Get-Content -Path 'list.txt'
  
  $bakups24 = Get-ChildItem -name -Path 'C:\BACKUPS' | Where-Object { $_.CreationTime -le (Get-Date).AddDays(-1) }
  
  foreach ($f in $list) {
      if-not ($backups24 -like "*$f*.*" {
          $f | Out-File -Append -FilePath 'C:\Backup Check\Missing backups.txt'
      }
  }
  </code></pre>
  
  <p>Clearly, the -like expression isn't working for some reason, because I have arranged for the files in c:backups to have names that include some of the elements in the list and some not. For the moment I'm forgoing the three different patterns.</p>
  
  <p>Some help would be appreciated, I don't care if it's in batch or Powershell format.</p>
  
  <p>Regards.</p>