Windows Powershell Version
This page covers the Windows PowerShell version of the script, you can get the Mac/Linux/Cygwin version here.
Instructions:
Step 1: Download the script
Download the script processfb.ps1 , and save it on your local computer to C:\facebook\processfb.ps1, or actually wherever you like. But creating a folder called C:\facebook is a good idea for this project.
Step 2: Download the friends list
As mentioned on the previous page, log into facebook, click on your own facebook page, and then Friends. The list appears. With your mouse, select the entire list of friends, but clicking and dragging over that area of the page. Then right-click Copy. In a text editor such as Notepad++ or any other basic text editor, paste the text. Save it as a plain text file in UTF-8 format. Name the file “friends.2024-11-15.txt”, for example, or put whatever today’s date is. Save the file into the directory we are using for this which is C:\facebook .
Step 3: Launch a Powershell Window
In the Search Box on the Taskbar in Windows, type Powershell. Right-click Powershell -> Run as Administrator
If this is the first time, paste this text into the window:
Set-ExecutionPolicy RemoteSigned
Run that, and Choose “Yes” when prompted.
Then also type the following, if you have not yet unblocked the script:
cd C:\facebook
Unblock-File .\processfb.ps1
Turn on Quick-Editing features:
Right-click on the top menu of Powershell, Properties, select Quick-Edit Mode. Ok.
Step 4: Run the script
Run the script as follows, in the Powershell window:
cd C:\facebook
.\processfb.ps1 friends.2024-11-15.txt
Replacing the filename with whatever your filename from Step 2 was. It will create the output file like “friends.2024-11-15.sorted.txt”, with the word “sorted” added.
Step 5: List Cleanup
Open the newly created file, from the previous step, in any basic text editor. Review it. It’s almost the cleaned-up list of friends, in alphabetical order, but it still contains some extra data such as names of Universities, Towns, Professional Titles. Unfortunately, this is the most laborious step, but it should only take a few minutes hopefully. ANY of the following choices will work, read through them.
Choice 1:
If the script is still running, and it’s prompting you to enter removal patterns, paste them into the script now. That is, paste in lines of text that shouldn’t be in the final output.
Choice 2:
The script has finished, but you can simply re-launch it.
.\processfb.ps1 friends.2024-11-15.txt
Enter the removal patterns, when requested. Re-run the script as often as necessary to add more removal patterns.
Choice 3:
In the file includefb.ps1, you will see this section, or if you don’t see it you can add it:
$personalpatterns=@(
“This is an example. You can replace the words here.”,
“And so is this. Paste in text you would like to delete from the output.”,
“Each entry should match an entire line of text. no more or less.”
)
You need to edit this section, with the items you want removed from your friend’s list. So after you do this, includefb.ps1 will look like this, as an example.
$personalpatterns=@(
“Harvard University”,
“Joe’s Paint Shop”,
“Gerbils”
)
Whatever text you observe in the friend’s list that you want removed, should be added to this personalpatterns list. Save the file. It is strongly recommended to save the file in UTF-8 text format, which is a choice when saving.
Run the script again now:
.\processfb.ps1 friends.2024-11-15.txt
Check the sorted output file again
friends.2024-11-15.sorted.txt
Still some extra data? Add it to personalpatterns. Rinse and repeat. Run processfb.sh again.
It’s important to keep in mind the concepts from Part 1. We are just trying to create a plain text list of friends. No more and no less. If something extra is appearing, put it into personalpatterns, so it will be removed when the script runs.
Step 6: Friend comparison
After a few months, you notice that your friend count is different. How to figure out who unfriended you? Go through steps 1-5 again, but with the new date. Today’s date. In other words, copy and paste your friends into a new file friends.2025-05-15.txt , run processfb.ps1 friends.2025-05-15.txt, and it generates the new output file friends.2025-05-15.sorted.txt
Compare the two sorted files from the terminal window. Run the “diff” command as “diff (cat old_file) (cat new_file)” Example:
diff (cat friends.2024-11-15.sorted.txt) (cat friends.2025-05-15.sorted.txt)
Just look at which friend names it mentions. Those are the “differences”. Who has left? Who was added?
That’s it.
Try it out. In the event you have questions, first consult the advanced documentation.
I look forward to your questions via the Contact Form