Hi,
We have a requirement where files in a particular directory get processed the corresponding business users need to be intimated via email. All the Directories and Sub-directories have email associated and all this information is saved in a comma separated file.
This is the ps script to send email. This works okay but when I have a file to process in “C:\Temp\Accounts\GL” and no included file in “C:\Temp\Accounts” it still sends out 2 different email to accounts@domain.com & accountsgl@domain.com.
Hi, For some reason file process duplication happens. My folder structure is “C:\Temp\SalesOrder\20160809\cc.txt” when its looking for all the files that need to be processed as soon as the recursion gets to folder “C:\Temp\SalesOrder” & “C:\Temp\SalesOrder\20160809” its processing cc.txt file. How do I rewrite the gci to not to traverse subfolders and only process files “C:\Temp\SalesOrder\20160809”
I want to process files only when the file that meets the criteria exists. For some reason even though I have just 1 file to process in all the folders put together it does process more than once and cannot figure out why? I have no hidden files either.
Check out the code I supplied in my previous post, it is your code just with the fix applied.
Specifically you mention the gci section as a problem, so remove the -Recurse, and add . onto the -path so it picks up the files, like so:
Get-ChildItem -Path "$($dir.FullName)*." -include .txt,.xls,.csv,*.xlsx
You don’t need to recurse on this call as you recursed earlier ($orgFolder = Get-ChildItem -Path c:\temp -recurse -exclude .)