wordpress - Loop through html files, get file name and insert into each file -
I am migrating a website to WordPress ... The old website uses a custom-built posting system where one PHP Templates There are many posts to migrate a call to separate static HTML files for each post (over 1000).
I am using a plugin that can import HTML files and can convert everyone into Wordpress post but it is important that the original date for each post is set correctly. , The plugin allows me to select the date from each HTML file in each file for each file.
My problem is that the date files are in file names, files themselves do not file, all the names are yy-mm-dd, but there is no dash, so they look like this:
"130726.htm"
(for July 26, 2013)
"121025.htm"
(for October 25, 2012)
So the original By the way, I want a way of loop through the directory of these files and for each one - get the file name, add a slash and <0>
; / Code>
I'm not sure that the best way to go about this ... a python script, a notepad + macro, batch file, or whatever help / suggestions / suggestions can give? They would be very appreciative!
Thanks in advance!
I made a mistake in understanding the question and the first script.
It scans the date directory through script files (I assume that the dates in the directory are just HTML files in your required format), and then opens the file and the paragraph under the body Includes.
Date folder:
121214.html 121298.html 121299.html
PHP script (script is placed as a dated folder in the same folder) :
& lt ;; Php $ dir = "date"; $ A = scander ($ dir); $ A = array_diff ($ a, array (".", "..")); Foreign currency ($ one $ value) {$ string = file_get_contents ("date /. $ Value); $ Newstring = substr ($ value, 0, -5); $ Newstring1 = substr ($ newstring, 0,2); $ Newstring2 = substr ($ Newstring, 2,2); $ Newstring3 = substr ($ Newstring, 4,2); $ paras = '& lt; p class =' origination '& gt; $ Newstring1. "/" $ Newstring2 "/" $ Newstring3 '& lt; / p & gt; . "& Lt; Br> "; $ pattern = '/ & lt; body [\ w \ s =" -:;] * & gt; / '; $ Replacement = '$ {0}'. $ Par; $ Newpara = preg_replace ($ patterns, $ substitution, $ string); $ Filename = "dates / $. $ Value; $ file = fopen ($ filename," r + "); fwrite ($ file, $ newpara); fclose ($ file);}? & Gt;
< / Pre>I used .html here, to use .htm, modify this line:
$ newstring = substr ($ value, 0, - 5);
$ newstring = substr ($ value, 0, -4);
sample Before HTML:
> DOCTYPE html>
Body; MarginWidth = 0 style = "margin-left: 30px;" onclick = "myfunction ( ) ">
- Tea
After the sample HTML: DOCTYPE html>
" 12/14 & lt; / p & gt; & lt; b & gt; & lt; ul & gt;- Coffee & lt; / li & gt; & lt; li & gt; Tea & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Comments
Post a Comment