Create a textfile listing all paths to a certain file or wildcard.


/ Published in: Windows PowerShell
Save to your folder(s)

First of all, for all Stackoverflow.com members who have seen my question about this snippet on Stackoverflow, yes I am the same person as WebDevhobo. Last time I asked a question about something I posted here I got a bucketload of comments saying I couldn't claim the work of that snippet to be mine >_>



This is a function for Windows Powershell. What this will do is create a list of all paths that lead to a certain file on your computer.


Example input: `listAllPaths c:\ *.zip c:\allZips.txt`

This will create a file allZips.txt under your root harddrive(the third parameter). The content will be a list of all paths to every file that ends with the characters .zip(second parameter) and Powershell will start looking from c:\(the first parameter)

You'll have to make sure Powershell knows the function first. So you'll have to add it to your Powershell profile, which will make it so that every time you start Powershell, you can use the function.

More info on the Powershell profile can be found [here][1]


[1]: http://superuser.com/questions/63446#63458


Copy this code and paste it in your HTML
  1. Function writeAllPaths([string]$fromFolder,[string]$filter,[string]$printfile) {
  2. Get-ChildItem -Path $fromFolder -Recurse $filter | Select-Object -Property FullName > $printfile
  3. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.