Answer the question
In order to leave comments, you need to log in
How to quickly replace numbers in documents of the same type with different ones in only one place?
For example, there is a document with content:
Programmer's site ..Go to content on page 1.
And there are 100 such files..With the same text.
Need the following.
1.php - find the number 1, replace with 2
2.php - find the number 1, replace with 3
2.php - find the number 1, replace with 4
And so 100 times. How to do it quickly?
Answer the question
In order to leave comments, you need to log in
Try this:
1. Back up your files
2. Create an update.js file (code below) in your files directory
3. Run node update.js
update.js
const fs = require('fs');
fs.readdirSync('.')
.filter(file => file.indexOf('.php') !== -1)
.forEach(file =>
fs.writeFileSync(file,
fs.readFileSync(file, { encoding: 'utf8' })
.replace('1', parseInt(file))));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question