Python Forum
rename and add desire "_date" to end of file name before extention
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
rename and add desire "_date" to end of file name before extention
#1
hi I have many folders that all of them have same 4 folders( annotation,measurment,preview,support) and 2 files( manifest.saf and .pdf extention) like this:
annotation

measurement

preview

support

manifest.safe

S1A_IW_SLC__1SDV_20220316T020357_20220316T020424_042340_050C30_FC59.SAFE-report-20220316T194123.pdf

I need to rename manifest file and add "_date" (that is mentioned in pdf file name for example 20220316)in S1A_IW_SLC__1SDV_20220316T020357_20220316T020424_042340_050C30_FC59.SAFE-report-20220316T194123.pdf
then i have:

manifest_20220316.safe
Reply
#2
So where exactly are you stuck?

You might want to explore using pathlib to handle the path/folder/filenames. Good article on this lib on RealPython.com. They also cover how to rename files.
I am trying to help you, really, even if it doesn't always seem that way
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  rename same file names in different directories elnk 5 2,343 Jul-12-2024, 01:43 PM
Last Post: snippsat
  Extract and rename a file from an Archive tester_V 4 3,450 Jul-08-2024, 07:54 AM
Last Post: tester_V
  Rename first row in a CSV file James_S 3 1,544 Dec-17-2023, 05:20 AM
Last Post: James_S
  rename file RolanRoll 0 1,059 May-18-2023, 02:17 PM
Last Post: RolanRoll
  '' FTP '' File upload with a specified string and rename midomarc 1 2,167 Apr-17-2023, 03:04 AM
Last Post: bowlofred
  count every 28 files and find desire files RolanRoll 3 2,980 Dec-12-2021, 04:42 PM
Last Post: Axel_Erfurt
  Rename Files based on XML file klturi421 3 3,368 Oct-22-2021, 07:37 PM
Last Post: klturi421
  How to rename a CSV file by adding MODIFIED in the filename? Python_User 25 12,792 Dec-13-2020, 12:35 PM
Last Post: Larz60+
  Rename docx file from tuple gjack 2 2,916 Oct-20-2020, 05:33 PM
Last Post: gjack
  Copy mp3 file multiple times and rename Mar10 4 4,955 Sep-23-2020, 01:09 AM
Last Post: Mar10

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020