TuxWraith
5 min readTutorials

Remove Korean Text from Multiple Folders on Linux

Share

How to Remove Korean Text from Multiple Folder Names on Linux

Do you have many folders whose names contain a mixture of Korean and English text? Renaming every folder manually can take a long time. On CachyOS and other Linux distributions, you can remove Korean text from multiple folder names at once with a simple Python script.

This tutorial uses a preview step before applying any changes. You can therefore review every new folder name and catch potential problems before performing the batch rename.

Example folder names

Suppose you have these folders:

새 폴더 My Project
한국 드라마 The Glory
음악 Collection

After removing the Korean text, their names will become:

My Project
The Glory
Collection

The script in this guide only renames folders. It does not delete the folders or any files stored inside them.

Requirements

Python is normally available by default on CachyOS. Confirm that it is installed by running:

python --version

If the terminal displays a Python version number, you can continue. Before processing an important collection, create a backup or test the commands on a few sample folders.

Open the parent folder in the terminal

Open a terminal and navigate to the directory containing the folders you want to rename:

cd "/path/to/parent/folder"

For example:

cd "/home/username/Videos/Drama"

Keep the quotation marks when the path contains spaces.

Confirm your current location with:

pwd

You can also list the folders in the current directory:

ls

Preview the folder name changes

Run the following script first. It only displays the proposed changes and does not rename anything:

python - <<'PY'
import os
import re

korean = re.compile(
    r"[\u1100-\u11FF\u3130-\u318F\uA960-\uA97F"
    r"\uAC00-\uD7A3\uD7B0-\uD7FF]+"
)

for root, dirs, files in os.walk(".", topdown=False):
    for name in dirs:
        new_name = korean.sub("", name)
        new_name = re.sub(r"\s+", " ", new_name).strip()

        if not new_name:
            print(f"SKIPPED, name would be empty: {os.path.join(root, name)}")
            continue

        if new_name == name:
            continue

        old_path = os.path.join(root, name)
        new_path = os.path.join(root, new_name)

        if os.path.exists(new_path):
            print(f"SKIPPED, name already exists: {old_path} -> {new_path}")
        else:
            print(f"PREVIEW: {old_path} -> {new_path}")
PY

Review every line marked PREVIEW. If all proposed folder names look correct, continue to the next step.

A SKIPPED message means that the script intentionally ignored a folder because its new name would be empty or another folder already uses the proposed name.

Remove Korean text from multiple folder names

Once you have checked the preview, run the following version to apply the changes:

python - <<'PY'
import os
import re

korean = re.compile(
    r"[\u1100-\u11FF\u3130-\u318F\uA960-\uA97F"
    r"\uAC00-\uD7A3\uD7B0-\uD7FF]+"
)

for root, dirs, files in os.walk(".", topdown=False):
    for name in dirs:
        new_name = korean.sub("", name)
        new_name = re.sub(r"\s+", " ", new_name).strip()

        if not new_name:
            print(f"SKIPPED, name would be empty: {os.path.join(root, name)}")
            continue

        if new_name == name:
            continue

        old_path = os.path.join(root, name)
        new_path = os.path.join(root, new_name)

        if os.path.exists(new_path):
            print(f"SKIPPED, name already exists: {old_path} -> {new_path}")
            continue

        os.rename(old_path, new_path)
        print(f"RENAMED: {old_path} -> {new_path}")
PY

The script processes subfolders recursively, starting with the deepest directories. This order prevents path errors when a parent directory also needs to be renamed.

How the script works

The script performs the following operations:

  1. os.walk() finds every folder under the current directory, including nested subfolders.
  2. The Unicode pattern identifies modern Korean syllables and several Hangul Jamo ranges.
  3. korean.sub("", name) removes the Korean characters from each folder name.
  4. Consecutive spaces are converted into a single space, while leading and trailing spaces are removed.
  5. The script skips a folder if its new name would be empty or conflict with an existing folder.
  6. os.rename() applies the new name without modifying the folder's contents.

Does the script rename files too?

No. This script only processes directory names. The names of videos, images, documents, and other files remain unchanged.

Renaming files requires an additional loop over the files list. It is safer to handle files separately so you can review those changes independently.

Does this work on other Linux distributions?

Yes. In addition to CachyOS, you can use this method on Arch Linux, EndeavourOS, Ubuntu, Debian, Fedora, openSUSE, and other Linux distributions with Python 3 installed.

Will it remove Japanese or Chinese characters?

No. The Unicode pattern in this script targets Korean Hangul characters. Japanese Hiragana and Katakana, as well as Kanji, are not included.

This distinction is important because many Kanji characters are shared with Chinese. Removing every CJK character without reviewing the results could unintentionally affect folder names written in other languages.

Safety tips for batch-renaming folders

  • Always run the preview version first.
  • Use pwd to confirm that the terminal is in the correct parent folder.
  • Back up important data before performing a large batch rename.
  • Review name-conflict messages before resolving skipped folders manually.
  • Do not run the script from your home or system directory when you only intend to process one collection.

Frequently asked questions

Will the contents of my folders be deleted?

No. The command only changes directory names. The files and subfolders inside them remain in place.

Why were some folders skipped?

The script skips a folder when removing its Korean text would leave an empty name or when another folder in the same location already has the proposed name.

Does the script remove extra spaces?

Yes. It removes spaces at the beginning and end of each new name and converts multiple consecutive spaces into one.

Can I automatically undo the changes?

This script does not save a rename history. Always use the preview step and create a backup before applying the changes to important data.

Conclusion

You do not need to edit folder names one by one to remove Korean text on CachyOS. With Python, you can recursively process multiple directories while protecting against empty names and naming conflicts.

Run the preview first, inspect every proposed change, and only use the rename version after confirming that the new folder names are correct.

Read more

How to Compress Images on Linux (Complete Guide)
Tutorials

How to Compress Images on Linux (Complete Guide)

Tutorials

Remove Japanese Text from Multiple Folders on Linux

How to Fix a Full Disk on a Linux Server (Step-by-Step Guide)
Tutorials

How to Fix a Full Disk on a Linux Server (Step-by-Step Guide)

Best Browsers for Linux in 2026: Top 8 Picks
Web Browser

Best Browsers for Linux in 2026: Top 8 Picks