<?php
$str = file_get_contents('test');
$i = 1;
while (preg_match('/Downloads/ui', $str)) {
$str = preg_replace('/Downloads/', $i, $str, 1);
$i++;
}
echo $str;
import string
import re
f = open("test", 'r')
n_text = f.read()
i = 1
while (re.search('Downloads', n_text)) :
n_text = string.replace(n_text, 'Downloads', str(i), 1)
i = i + 1
print(n_text)
Думаю на перле можно запилить что-то аналогичное, увы, но в нем я не очень силен