removing period from file names

Bill Campbell bill at celestial.com
Wed Oct 2 14:26:07 PDT 2019


On Wed, Oct 02, 2019, scooter6--- via Filepro-list wrote:
>I have a bunch of XML data I import to a filePro database (5.6.10R4) on
>CentOS 7
>
>Several of the fields are names of files that have been uploaded to the
>same server
>
>We get silly client that like to name their files something like:
>T01245.John.Smith_Statement.Oct2019.pdf

I would do this with a simple python script like the following.
I would add some code to make it more robust such as a try:
except around the n = s.rindex('.') in case the file didn't
contain a '.' character

#!/usr/bin/env python
import sys, os
for s in sys.argv[1:]:
    n = s.rindex('.')
    o = s[:n].replace('.', '_') + s[n:]
    if s != o:
        os.rename(s, o)
sys.exit(0)

Bill
-- 
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www2.celestial.com/ 6641 E. Mercer Way
Mobile:         (206) 947-5591  PO Box 820
Fax:            (206) 232-9186  Mercer Island, WA 98040-0820

"The liberties of a people never were, nor ever will be, secure, when the
transactions of their rulers may be concealed from them." -- Patrick Henry


More information about the Filepro-list mailing list