Niche filename issue I'm hoping someone can help me with

  • 🐕 I am attempting to get the site runnning as fast as possible. If you are experiencing slow page load times, please report it.

skykiii

kiwifarms.net
Joined
Jun 17, 2018
Okay, here goes:

I have a Windows 7 laptop I sometimes use to watch videos in bed or when I'm away from home.

Windows 7 however can not see files that have certain symbols in their filename.

I have a bunch of downloaded youtube videos that have such symbols and it would be time-consuming to manually rename them all.

I've heard there's programs that automatically rename files to make then seeable by older versions of Windows but I have no idea what these programs are called.

Before you say "just google it" this is a case where I don't even know what terms I should be searching for, and "renames files so that Windows 7 can see them" got me a bunch of useless hits.

Anyway, do Kiwis know of a program that might help me out here?

Thanks in advance.
 
What do you mean by "can't see them"? What video player are you using? What characters?
The operating system itself can't see files whose names have certain characters. If you plug a drive containing them into Windows 7 or XP the file will not be there as if it doesn't exist. I think I had a case where a PDF file somehow did manage to show up but then couldn't be loaded because a character used confused the OS.

Like for example:

"Blaster Master | NES | full manual {scan}.pdf" ... the | and { } symbols will confuse 7 and XP.

"Is this the scariest horror game of the year????.mp4" my memory is XP couldn't handle question marks in filenames.

For the sake of clarity, you're not talking about common symbols that are not allowed in Windows file names like "/" are you?
Might be some overlap. What I do know is right now I'm mass-downloading videos from a youtube channel and a lot of the filenames are ones I know Windows 7 will not be able to handle without issue.
 
Yeah, you probably can make an easy script in Python using the os module (and something like "for file in os.listdir()" and the "os.rename()" function), and basic knowledge in regex (you only have to know what \w means in order to filter out undesired characters).

I have not made that script, but that would do it if you decide to research this.
 
Yeah, you probably can make an easy script in Python using the os module (and something like "for file in os.listdir()" and the "os.rename()" function), and basic knowledge in regex (you only have to know what \w means in order to filter out undesired characters).

I have not made that script, but that would do it if you decide to research this.
This assumes I know how to program in Python.

(Just to be clear, I have zero knowledge of programming).
 
It would probably be something like this.

Note: I have NOT experiemented with this, and there is no file name collision managing, but that's unlikely. This is just me putting something together in a couple of minutes so that you may improve on it, by doing basic Google searches and maybe asking AI. But it's the basic gist of it, you don't need extensive knowledge.
Python:
import pathlib
import os
import re

for file in os.listdir():
  if os.path.isfile(file):
    name = pathlib.Path(file).stem
    extension = pathlib.Path(file).suffix if pathlib.Path(file).suffix else ""

    new_name = re.sub(r"\W", "x", name)

    os.rename(file, f"{new_name}{extension}")

In essence, this can be a stepping stone for you to do research on, do not rely on this script.
 
In essence, this can be a stepping stone for you to do research on, do not rely on this script.
Do a "clobber check" before directly using the rename command. Add an if statement that stops the program if the new file name already exists. Otherwise the program deletes files, even though the command is called "rename".
 
If you use yt-dlp direclty using a cmd window, you can use the option "--restrict-filenames" in your command to replace every special characters with underscores. If you're using a website to download the youtube videos then I'd maybe say ask ChatGPT to make a sloppy batch file that would replace every special charcters in every file of your video folder. That's how I usually do it.
 
I thought you could not save files in Windows if it has certain symbols?
some programs can, windows is notoriously shitty in that regard because it assumes just because the windows dialog doesn't allow it it doesn't happen - to the point you can wreck explorer being unable to handle said files that shouldn't exist anyway.
here's a hint in case that happens: rename/delete them with 7zip's file browser.
 
+1 for bulk rename utility, useful for organising.

Are you sure it's characters and not something i encountered years ago where I was unzipping a file but it was nested and hit a character limit that caused issues.
MAX_PATH is Limited to 250(?!) on win7.

Pretty sure even if you can't code you can ask Gemini or some other ai to write you a workable python script these days.
 
I thought you could not save files in Windows if it has certain symbols?
Back in the day I recall youtube downloaders would just automatically rename files to get around this.

Can you download another alphabet so it recognizes the characters? Are they Greek or Japanese characters?
It's not even a "foreign languages" issue, its just certain ascii characters that older Windows don't like in filenames.
 
Do a "clobber check" before directly using the rename command. Add an if statement that stops the program if the new file name already exists. Otherwise the program deletes files, even though the command is called "rename".
How about something like this? Again, I have not tested this properly, but seems to work for simple stuff.
Python:
import pathlib
import os
import re

for file in os.listdir():
  if os.path.isfile(file):
    name = pathlib.Path(file).stem
    extension = pathlib.Path(file).suffix if pathlib.Path(file).suffix else ""

    undesired = bool(re.search("[^A-Za-z0-9_\- ]", name))

    if undesired:
      new_name = re.sub(r"[^A-Za-z0-9_\- ]", "_", name)

      counter = 1

      if os.path.exists(f"{new_name}{extension}"):
        while os.path.exists(f"{new_name}{extension}"):
          new_name = f"{new_name}_{counter}"
          counter += 1

      os.rename(file, f"{new_name}{extension}")
 
Back