Reputation: 1
I just started working powershell. Any help on below query would be great help.
I have a input.txt file containing filenames(one filename in a line) and I have those files in different drives, different folders and sub-folders. Note: All the files are of .WAV. My input.txt just contains the filename(something like 'filename', but not 'filename.WAV')
Question: I am looking for the Powershell script to read the input.txt file to read each line(filename) by line and then get fullpath of that file located in the drives and folders and sub-folders and print the fullpath of each file line by line in output.txt file
Any help would be highly appreciated.
Tried: Since I am new, I could only try the below script to get the content of my input.txt as below:-
$input = Get-Content -Path "C\GetFullPath\input.txt" -Force
Write-Output $input
foreach($line in $input)
{
}
Upvotes: 0
Views: 59
Reputation: 16096
This is the very basic of PowerShell, with full examples in the help files, all over the web and even videos on Youtube. A quick search for 'PowerShell file and folder management', will give you a long list to sample.
But for your code, you just need to ask for the property.
Just using Get-ChildItem on a Directory, and asking for the FullName property, will do.
(Get-ChildItem -Path D:\Temp).FullName
You can do this same thing when reading in a list of filenames.
As far as different disks, you have to pass those in as well, and for different folders, you'd use the
-Recurse
switch to get folders and subfolders.
All you need is in the help files and the examples there.
Upvotes: 1