In the daily data processing task, we always need to copy or move files from multiple source place to one destination folder. In this blog, I’ll show you how to do those task quickly and easily via PowerShell.
I am using below code to move all csv files under Archives folder to Source folder. Archives folder has more than thousands sub-folders.
In this blog, I will show you how to use powershell Select-String cmdlet to string or words from multiple files on Windows quickly?
Select-String is based on lines of text. By default, Select-String finds the first match in each line and, for each match, it displays the file name, line number, and all text in the line containing the match.
Find matches in special files
This command searches all files with the .php file name extension in the current directory
select-string *.php -pattern function
The output displays the lines in those files that include the specified string.
Find a string in subdirectories
This example searches a directory and all of its subdirectories for a specific text string.
Get-ChildItem uses the Path parameter to specify folder, The Include parameter indicate the file type will be searched The Recurse parameter includes the subdirectories. The objects are sent down the pipeline to Select-String.
Select-String uses Pattern parameter and specifies the string ‘ function posted_on ‘
I have a simple powershell project to do file copy and sync task. Can I get email notification if task has issue, like error message or copied file name. The answer is yes, we can us Net.Mail.SmtpClient to send out email in powershell.