Jump to content

TXT File To Lower Case [Phaselis Map Works]


Recommended Posts

With this exe user will enter the adress of the file and all txt type file names will turn into lowercase ones. I created this program because when I make a new map I had files name like MapSetting.txt, AreaAmbianceData.txt and it will cause problem to one of my clients now I can make them lowercase and problem is solved.

How to use:https://metin2.download/video/4tQiPWzfkd6xa7Lf7417QSHTmhDsgKpk/.mp4

Mega Link: 

This is the hidden content, please

This is the hidden content, please

  • Metin2 Dev 1
  • Good 2
Link to comment
Share on other sites

  • Premium

for py users

import os

# function to rename files
def rename_files(path):
  for dirpath, dirnames, filenames in os.walk(path):
    for filename in filenames:
      # check if filename contains uppercase characters
      if any(c.isupper() for c in filename):
        # rename file to lowercase
        os.rename(os.path.join(dirpath, filename), os.path.join(dirpath, filename.lower()))

# enter the path of the directory to rename files
path = input("Enter directory path: ")
rename_files(path)

print("All files have been renamed to lowercase.")

 

  • Good 1

plague.png.1f5de75b42146262dcd655a5a8078

Link to comment
Share on other sites

15 hours ago, DemOnJR said:

for py users

import os

# function to rename files
def rename_files(path):
  for dirpath, dirnames, filenames in os.walk(path):
    for filename in filenames:
      # check if filename contains uppercase characters
      if any(c.isupper() for c in filename):
        # rename file to lowercase
        os.rename(os.path.join(dirpath, filename), os.path.join(dirpath, filename.lower()))

# enter the path of the directory to rename files
path = input("Enter directory path: ")
rename_files(path)

print("All files have been renamed to lowercase.")

 

this is an extra option yep but I want to remane specificly .txt files, for users I can recommend them to use this code with a little modify;

Use a list comprehension instead of the for loop to check if the filename contains uppercase characters.

Use os.path.splitext() method to get the file extension, and then concatenate it with the lowercase filename.

Use the r prefix for the input() function to interpret backslashes as part of the path string.

import os

def rename_files(path):
    # Use os.scandir() instead of os.walk() for better performance
    for entry in os.scandir(path):
        if entry.is_file():
            # Get the filename and extension separately
            filename, ext = os.path.splitext(entry.name)
            if any(c.isupper() for c in filename):
                # Rename file to lowercase and concatenate the extension
                new_name = filename.lower() + ext
                os.rename(entry.path, os.path.join(path, new_name))

# Use the r prefix for the input function to interpret backslashes as part of the path string
path = input(r"Enter directory path: ")
rename_files(path)

print("All files have been renamed to lowercase.")

maybe this could be the my solution for py user,

thanks for contribution to my topic

Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.