removing period from file names

Fairlight fairlite at fairlite.com
Wed Oct 2 15:42:36 PDT 2019


If even you didn't go for sed, I think I can give up on my thought of
trying to go for a non-Perl sed version.  :)

I'm surprised you recommend keeping much of the original filename at all.
I would drop most of it for sanity's and security's sakes, and just use an
SHA1 or MD5 digest string with the appropriate suffix, properly
sanitised/checked.

m->


On Wed, Oct 02, 2019 at 02:26:07PM -0700, Bill Campbell via Filepro-list thus spoke:
> 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
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> Subscribe/Unsubscribe/Subscription Changes
> http://mailman.celestial.com/mailman/listinfo/filepro-list
> 

-- 
Audio panton, cogito singularis.


More information about the Filepro-list mailing list