Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

test-path where a directory in the path is variable

$
0
0

My company has a series of fax lines and associated file shares. Faxes are processed & then dropped off into these file shares. From that point a service runs about every 60 seconds to look for files in these directories to import into a database.

If there is a problem with the import then the service moves the file to a "HOLD" folder & files remain there until human intervention.

I am trying to create a script that will find the HOLD directory in each of these folders and look for the existence of files, then email a group of users alerting them if there are.

So there are several things I'm trying to accomplish.

1. Look for files in a path where a folder in the middle of the path is variable.

2. Send and email that will inform the recipient that there are files in the HOLD folder(s) and tell them WHICH ones

Here's what I am starting with but it isn't working as expected.  There are files in at least one of these.  I also thought to try using some kind of foreach loop but it's eluding me.  Probably because it's late in the day for me.

$folder = get-content -Path "\\child.domain.com\netlogon\scripts\ps\numbers.txt"

if(Test-Path -Path "\\Server\scan import\fax\$folder\Hold" -include *.pdf, *.tif, *.jpg) {write-host "Files exist at $folder"} Else {write-host "No files in the hold folders"}


# When I wrote this script only God and I knew what I was doing. # Now, only God Knows!


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>