Hi,
I am new to PS and I am looking for a solution/script to perform below task.
Requirement: I have a text file contains list of filenames(ex: AB-12-LOG, XY-23H-LOG etc) and I need to copy all those listed files from the folder C:\2021\04April to C:\Destination
Hi @rameshsagar, there wont be a script readily available here for this. But we can help you write one for sure.
First thing required here is to have a cmdlet to read the file, which will be Get-ChildItem
Then you would iterate through each lines in the file where each line is a filename, for that you will use ForEach-Object cmdlet.
Then its a matter of using Copy-Item cmdlet to copy using -Path and -Destination parameters. You would be using $_ as the current item during the iteration using ForEach-Object cmdlet (which is detailed in the cmdlet help and examples).
Hope above info helps you, let us know if you face any doubts in writing a script using above tips with your code.
Please be sure to include and use the FullName property in the program code as this is the unique identifier for the file item. This reduces the chance of unintended outcomes when recursion or depth is specified.