New Forever Loop: The FIFO Queue

Usually when I run, I don’t want to re-run my links/accounts/whatever in the event that I stop and re-start the script. This is the same idea when running the script from task manager, you want it to always use fresh links that haven’t been used in a while.

Enter the FIFO loop - FIFO = First In, First Out.

The way that it works, is that always reads the first line of the file, and the last action of the loop is to run a powershell script that takes the first line of the file, and then appends it to the end of the file.

The powershell looks like this:

# Set the file path...
$file = "C:\\datasources\targets.csv"
# Get just the first line of the file...
$line = Get-Content -Path $file -TotalCount 1
# Chop that first line off of the file...
(Get-Content $file | Select-Object -Skip 1) | Set-Content $file
# Append the first line back on to the end of the file...
Add-Content $file "$line"

I think you should be able to figure the loop out, but if you’d like to see it, just let me know!

Thanks for this useful script! Another method to achieve the same is to mark the used lines as “processed”: How to mark a row in a CSV line as processed? - #3 by TechSupport