Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8542007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:57:37+00:00 2026-06-11T11:57:37+00:00

I am trying to make a script that can scramble a folders files and

  • 0

I am trying to make a script that can scramble a folders files and the files content on a windows machine.

This was my first attempt at trying to scramble file names in a folder. I know performance wise its probably terrible and it looks pathetic but I’m new and trying to teach it to myself.

import os
import sys
import re
root = 'C:/Users/Any/Desktop/test'

for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' A', ' ಌ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' B', ' ௷'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' C', ' അ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' D', 'ጯ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' E', 'ᚙ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' F', ' ᚘ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' G', ' ௲ '))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' H', ' ණ '))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' I', ' ┩'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' J', ' ວ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' K', ' ʥ '))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' L', ' ቄ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' M', ' ఈ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' N', '㏁'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' O', ' Ꮄ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' P', '♙'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' Q', ' Ꮬ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' R', ' ꡤ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' S', ' ⏎'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' T', ' ௷'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' U', ' ヌ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' V', ' ஹ '))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' W', '  ̉'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' X', ' ฟ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' Y', ' ॢ'))
for item in os.listdir(root):
    fullpath = os.path.join(root, item)
    os.rename(fullpath, fullpath.replace(' Z', ' ╔'))

The folder content before running the script was:

FILENAMEABCDEFGHIJKLMNOPQRSTUVWSTXYZ.docx
TEST PICTURE.jpg
TEST SCRIPT.bat
TEST TEXT.txt

After running the script:

FILENAMEABCDEFGHIJKLMNOPQRSTUVWSTXYZ.docx
TEST ௷EXT.txt
TEST âŽCRIPT.bat
TESTâ™™ICTURE.jpg

So what the heck happened? It was suppose to be so simple how could it produce results like this? What should I do to try to make a scrambling script, it doesn’t have to be advance cause I want to understand it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:57:38+00:00Added an answer on June 11, 2026 at 11:57 am

    There are several problems with your approach.

    1. Each search string starts with a space, so it will only replace a space and the character immediately following it.
    2. Your replacement characters are unicode literals, but you haven’t specified an encoding in your script (or used unicode literals). The result will likely be UTF-8 encoded bytes from your text editor interpreted as latin-1 by Python and sent to the OS as Unicode codepoints — i.e. mojibake.
    3. You’re using a hugely inefficient method of performing the replacements. Use the .translate method of strings and pass in a mapping table of characters to Unicode replacements; then you only have to loop over your files once, and perform the translation using an efficient lookup instead of a lengthy series of replaces. Any time you find yourself needing to copy-paste a piece of code 3 or more times, ask yourself if a loop or some other technique might work better — there’s never any good reason to repeat yourself 26 times.
    4. You import re but don’t actually use it.

    Here’s what I’d write the code as, taking into account all of the notes above:

    import os
    
    # unicode.translate translates *code points* to unicode literals,
    # so we apply ord to the letters to get code points
    # We also specify our Unicode literals using escape notation to avoid encoding issues.
    TRANSTABLE = {
        ord(u'A'): u'\u0123',
        ord(u'B'): u'\u2931',
        # etc
    }
    
    # Unicode literal so that os.listdir produces Unicode filenames
    # Raw (r) literal so that backslashes are interpreted literally
    ROOT = ur'C:\Users\Any\Desktop\test'
    
    for filename in os.listdir(ROOT):
        newname = filename.translate(TRANSTABLE)
        # Don't translate ROOT (avoids translating e.g. the C in C:\)
        os.rename(os.path.join(ROOT, filename), os.path.join(ROOT, newname))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a script that can generate a kind of chat client
I am trying to make a script that lists only folders within a folder.
I'm trying to make search terms bold in this search script that I'm making.
I am trying to make a script (on linux) that can turn a light
I am trying to make a bash script that moves a file or directory
I'm trying to make a script that will generate a .WPL file. The script
i am trying to make this script that filters a line coming from ps..
I'm trying to make a script so that I can easily add host types
I'm trying to make a script that sends a file from my server to
I'm trying to make a script that zooms into an image. This is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.