You can use the following in a batch file: (I am assuming Windows though)
adb shell pm list packages org.kde.necessitas.example > packages.txt
for /F "tokens=2 delims=:" %%a in (packages.txt) do adb shell pm uninstall %%a
You could take it a step further and make the search text a parameter:
adb shell pm list packages %1 > packages.txt
for /F "tokens=2 delims=:" %%a in (packages.txt) do adb shell pm uninstall %%a
This pipes the output of the pm list packages
command into a text file and then loops through each line of the text file. It calls adb shell pm uninstall
for each second token in the line which in this case is the package name.