Quantcast
Channel: Total Commander
Viewing all articles
Browse latest Browse all 4256

Total Commander (English) • Re: Change of substring in file names

$
0
0
You can accomplish this task using a scripting language like Python. Here's a Python script that renames files in bulk according to your specifications:

Code:

 import osimport re# Define the directory containing the filesdirectory = "/path/to/your/directory"# Define the regex pattern to extract the number from the filenamepattern = re.compile(r"#Tableau Course #(\d{1,3})\.mkv$")# Iterate over each file in the directoryfor filename in os.listdir(directory):    # Check if the file is an MKV file    if filename.endswith(".mkv"):        # Extract the number from the filename        match = re.search(pattern, filename)        if match:            number = match.group(1)            # Rename the file            new_filename = f"{number.zfill(3)} {filename.replace('#Tableau Course #' + number, '').strip()}"            os.rename(os.path.join(directory, filename), os.path.join(directory, new_filename))            print(f"Renamed {filename} to {new_filename}")
Make sure to replace "/path/to/your/directory" with the path to the directory containing your files.
This script extracts the number from the filename using a regular expression, formats it to be zero-padded to 3 digits, and then inserts it at the beginning of the filename.
Fine thanls dear friend :shock: :) :D :wink: .

Att.

DruidCtba®.

Statistics: Posted by DruidCtba — 2024-04-30, 20:52 UTC



Viewing all articles
Browse latest Browse all 4256

Trending Articles


Vimeo 10.7.1 by Vimeo.com, Inc.


UPDATE SC IDOL: TWO BECOME ONE


KASAMBAHAY BILL IN THE HOUSE


Girasoles para colorear


Presence Quotes – Positive Quotes


EASY COME, EASY GO


Love with Heart Breaking Quotes


Re:Mutton Pies (lleechef)


Ka longiing longsem kaba skhem bad kaba khlain ka pynlong kein ia ka...


Vimeo 10.7.0 by Vimeo.com, Inc.


FORECLOSURE OF REAL ESTATE MORTGAGE


FORTUITOUS EVENT


Pokemon para colorear


Sapos para colorear


Smile Quotes


Letting Go Quotes


Love Song lyrics that marks your Heart


RE: Mutton Pies (frankie241)


Hato lada ym dei namar ka jingpyrshah jong U JJM Nichols Roy (Bah Joy) ngin...


Long Distance Relationship Tagalog Love Quotes