H
He Who Greets With Fire
I am trying to write a little script to access many files in folder,
parse each file and then if a certain string is found, rename the file
using a substring of that found string.
OK, I have posted here before many many years ago (around 2001), back
when I did some perl programming. I even wrote a program as my senior
project to parse financial news stories and assign values to the
stories based on whether there were negative or positive words in the
news stories.
Some people here helped me with that program, and when I finished that
project I posted the code to the web.
Now I need some more help.
I have not programmed in a long time. I know perl has changed
somewhat. I have downloaded the latest activestate win32 perl and
installed it.
I have a file directory named E:/personalinjury. In the file directory
are 821 files named from 1.htm to 821.htm
I want to access each file in turn, and use a regex to parse the file
contents to see if a string similar to this one is found in it:
Citation: 20-333 Dorsaneo, Texas Litigation Guide § 333.103
Some files will not have a string similar to the above string. I am
not interesting in renaming those files.
If the string above is found, the numbers 20-333 and 333.103 will be
the ones that vary from file to file. All the words in the string
above and the section symbol will remain the same from file to file.
So another string I might find might be:
20-332 Dorsaneo, Texas Litigation Guide § 332.107
I am interested in that string of numbers at the end; in the examples
above, it is 333.103 and 332.107, but there are many other variations.
So, I want to rename that file to 333.103 from whatever it was before
(e.g., so I would rename the file from 1.htm or 5.htm or 200.htm etc
to 333.103.htm or 333.105.htm or 332.203.htm or whatever).
So, my script should strip off that string of digits and the end,
including the decimal point, and rename the file using that string of
digits.
Anyone got any ideas?
thx
parse each file and then if a certain string is found, rename the file
using a substring of that found string.
OK, I have posted here before many many years ago (around 2001), back
when I did some perl programming. I even wrote a program as my senior
project to parse financial news stories and assign values to the
stories based on whether there were negative or positive words in the
news stories.
Some people here helped me with that program, and when I finished that
project I posted the code to the web.
Now I need some more help.
I have not programmed in a long time. I know perl has changed
somewhat. I have downloaded the latest activestate win32 perl and
installed it.
I have a file directory named E:/personalinjury. In the file directory
are 821 files named from 1.htm to 821.htm
I want to access each file in turn, and use a regex to parse the file
contents to see if a string similar to this one is found in it:
Citation: 20-333 Dorsaneo, Texas Litigation Guide § 333.103
Some files will not have a string similar to the above string. I am
not interesting in renaming those files.
If the string above is found, the numbers 20-333 and 333.103 will be
the ones that vary from file to file. All the words in the string
above and the section symbol will remain the same from file to file.
So another string I might find might be:
20-332 Dorsaneo, Texas Litigation Guide § 332.107
I am interested in that string of numbers at the end; in the examples
above, it is 333.103 and 332.107, but there are many other variations.
So, I want to rename that file to 333.103 from whatever it was before
(e.g., so I would rename the file from 1.htm or 5.htm or 200.htm etc
to 333.103.htm or 333.105.htm or 332.203.htm or whatever).
So, my script should strip off that string of digits and the end,
including the decimal point, and rename the file using that string of
digits.
Anyone got any ideas?
thx