I am wanting to rename 1k files using python. they are all in the format somejunkDATE.doc
basically, I would like to delete all the junk, and only leave the date. I am unsure how to match this for all files in a directory.
thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If your date format is the same throughout, just use slicing
If you want to check if the numbers are valid dates, pass
file[-12:-3]totimeordatetimemodule to check.Say your files are all in a directory (no sub directories)