1π
β
2.py
is run for each file and has no knowledge of the counter set in a previous run. One solution is to only run 2.py once and pipe in the files you want processed:
import sys
import time
def callme(filename):
print filename
for count,line in enumerate(sys.stdin):
if count and not(count % 10):
print('sleeping')
time.sleep(1) # I got bored.... make that 10
callme(line.strip())
And your script becomes
find /home/some/SomeElse/HeyMore -type f | python 2.py
If you donβt want find
hanging around pumping data, you could pull the files in all at once and then process them
filenames = [line.strip() for line in sys.stdin.readlines()]
...
π€tdelaney
Source:stackexchange.com