-3

I am looking to create a large number of rather small php files based off a pre-defined list. I would also like to insert something into these .php files. I have the list ready and there are just slightly over 7500 files to create. Each line is a different PHP file, such as

Cheese.php
Cheeese.php
Cheeeese.php

You get the idea, they change slightly. The list is already in a text file and I need to read the text file line-by-line and create a file using that line. I already know the command to create files through command line is fsutil file createnew I am just looking for a way to make it do this by using the massive text file and then also add the same pre-defined text into each of the PHP files that I am creating.

Can anyone help point me in the right direction? I would do this manually but 7500 is a bit time consuming!

user2195574
  • 57
  • 1
  • 8
  • 2
    Why on earth do you need 7500 php files? Perhaps you should look for a url router script – Steve Jul 13 '14 at 20:26
  • Is it a command line or a php question ? – David Jacquel Jul 13 '14 at 20:46
  • just a crazy idea, one php file, and one rewrite, rule can handle every request to a server. –  Jul 13 '14 at 20:56
  • My reasons are a little outlandish, safe to say it's more of an experiment. This is a command line question as per the title, it's just for creating `php` files. Unfortunately, a single php file in this instance won't do. I know what you mean as I tend to keep almost everything centered around a single file and branch off from it :) – user2195574 Jul 14 '14 at 08:12

1 Answers1

2

To do this in a batch-file is fairly simple:

for /f "delims=" %%a in (phplist.txt) do (
Echo. >> "C:\Path\To\MainDirectory\%%~a"
) 

The above will create all the listed files blank.

You can modify this by replacing the middle line with whatever you want and refering to the file names as %%~a.

Monacraft
  • 6,510
  • 2
  • 17
  • 29