Windows Illegal Character Help

Bulk Rename Utility How-To's

Windows Illegal Character Help

Postby CliffyBoy » Sun Apr 19, 2020 10:02 pm

Hello,

I am a new user to BRU. Does BRU have the capability to do a recursive scan through a drive to determine the existence of any folder/file that contains leading/trailing spaces and/or any other illegal windows characters? Once identified, then rename to acceptable status. I'm not familiar with regex so this is likely beyond my current capability to figure out if BRU can even accomplish this.

Any assistance would be appreciated.


Thanks,
CliffyBoy
 
Posts: 24
Joined: Sun Apr 19, 2020 9:36 pm

Re: Windows Illegal Character Help

Postby CliffyBoy » Sun Apr 19, 2020 11:25 pm

I' have about 50 folders that have trailing spaces but BRU returns an error message when trying to rename them:
Error. The system cannot find the file specified.
CliffyBoy
 
Posts: 24
Joined: Sun Apr 19, 2020 9:36 pm

Re: Windows Illegal Character Help

Postby Admin » Mon Apr 20, 2020 2:57 am

Hi, can you rename these folders manually with Windows File Explorer?
Admin
Site Admin
 
Posts: 1896
Joined: Tue Mar 08, 2005 8:39 pm

Re: Windows Illegal Character Help

Postby CliffyBoy » Mon Apr 20, 2020 6:12 am

No, I get the same message windows cant find the file. It cant be renamed or deleted until the trailing space is deleted. I've used a program called DelinvFile which enables me to either delete the folder/file or rename it. The problem is I can only do 1 at a time.
CliffyBoy
 
Posts: 24
Joined: Sun Apr 19, 2020 9:36 pm

Re: Windows Illegal Character Help

Postby therube » Mon Apr 20, 2020 12:03 pm

Leading spaces are not invalid.
Not sure if you can have "trailing" spaces?

What are these other illegal characters?

Examples of some of these file/directory names that are affected.

Perfectly valid:
Code: Select all
       this is a tset
       this is a tset       .TXT
  abc123  .txt
(03) Are There Any More Real Cowboys  .mp3


Renaming file with final dot or period
How Should Everything Handle file with a final dot or period
therube
 
Posts: 921
Joined: Mon Jan 18, 2016 6:23 pm

Re: Windows Illegal Character Help

Postby CliffyBoy » Mon Apr 20, 2020 2:07 pm

Thanks for replying. I agree the examples you provided would pass as legal but that's not my issue. By illegal characters I mean:

Windows: < (less than) > (greater than) : (colon - sometimes works, but is actually NTFS Alternate Data Streams) " (double quote) / (forward slash) \ (backslash) | (vertical bar or pipe) ? ( question mark) * (asterisk) _ (Leading or Trailing spaces)

I know normally that Windows will not allow you to create folders/files that contain any of the above, but unfortunately does allow for certain files/folders to be copied into Windows and thus be unrecognized and undeletable. This also includes files/folders with characters that extend past the maximum file/path length.

My imported (copied from cloud server) files/folders include some that have trailing spaces in the file/folder name. For example:
Folder Animals.com_ (trailing space) instead of Animals.com (no trailing space).
File owl.jpg_ (trailing space) instead of owl.jpg (no trailing space)

Some Mac/Linux systems allow for file/folder names with trailing spaces but Windows doesn't. I've fournd two programs that can either delete or rename files/folders like this but DelinvFile will only let me do 1 file at a time. Far Manager 3 also can delete or rename files/folders but I cant figure out how to batch rename/delete anything.

With BRU I was hoping it could do the job for me in bulk.

Thanks


P.S. The seedbox admin of the cloud server I use gave me a script to find and rename files/folders on the server prior to downloading:

First, to check which files/folders would be affected:
find . -name '* '
And then you can add some options to make it rename to remove the trailing whitespace:
find . -name '* ' -exec perl-rename -v 's/ +$//' {} +

I run this prior to FTP files from the server now and it works great. The issue is to find and fix files/folders that I downloaded to Windows prior to discovering this problem and server solution. I need to check at least 10TB and if I find any issues I can't try to fix them 1 at a time.
CliffyBoy
 
Posts: 24
Joined: Sun Apr 19, 2020 9:36 pm

Re: Windows Illegal Character Help

Postby CliffyBoy » Mon Apr 20, 2020 2:20 pm

If you need samples of the folders i can forward a link for you to test
CliffyBoy
 
Posts: 24
Joined: Sun Apr 19, 2020 9:36 pm

Re: Windows Illegal Character Help

Postby RegexNinja » Mon Apr 20, 2020 2:24 pm

BRU cant rename file/folders with illegal-chars like: \/:?*"<>|
This likely applies to folder-names that end with a space, as well.
I've heard that the 7zip file-manager can handle them, though.

FileBoss might be able to mass-rename such file/folders.. I've never actually tried it.
I do know it caters to finding/renaming problem files with: bad paths, illegal chars, etc.
BRU might help you find such bad file/folder-names, if that helps:

Folder-names ending with space:

#12Filters:
Mask= $
Folders/SubFolders=Checked
F5/Refresh to apply the filters


File/folder-names the begin and/or end with spaces, and/or contain: \/:?*"<>|

#12Filters:
Mask=^ | $| +\..{3,4}$|[\/:*?"<>|]
Folders/Files/SubFolders=Checked
RegEx=Checked
F5/Refresh to apply the filters

Again, it might help you find the problem file/folders, but not actually rename them.
But maybe you could: Right-click/ClipBoard-Copy to put those names into a text-file.
Then use another app (that's not as dependent upon Windows) to perform the renames.

Once you manage to kill all of the illegal character situations...
This removes leading/trailing spaces from filenames, and leading spaces from folder-names:

#1Regex Match/Replace:
^ *(.*?)[ ]*$
\1

Hope it helps.. Cheers!
RegexNinja
 
Posts: 134
Joined: Fri Feb 21, 2020 5:26 pm

Re: Windows Illegal Character Help

Postby CliffyBoy » Mon Apr 20, 2020 3:11 pm

Thanks RegexNinja, this is the issue exactly. I will try out your possible solutions and get back to you. Thanks
CliffyBoy
 
Posts: 24
Joined: Sun Apr 19, 2020 9:36 pm

Re: Windows Illegal Character Help

Postby RegexNinja » Mon Apr 20, 2020 4:07 pm

I just checked the FileBoss site, and it looks like that's something they might be advertising for the next version??
I hope that's not the case, considering: http://www.theutilityfactory.com/problem-files/fix-illegal-characters-in-filenames.htm
(Fingers crossed).
RegexNinja
 
Posts: 134
Joined: Fri Feb 21, 2020 5:26 pm

Re: Windows Illegal Character Help

Postby therube » Tue Apr 21, 2020 12:38 pm

If you need samples of the folders i can forward a link for you to test

I'm not sure how to visualize a file name that contains a trailing space(s) (or other non-printable characters) ;-)?
Find them, yes, but how to see?

Similarly, when you copy files from a foreign system to Windows, what copy method are you using that allows the creation of file names with illegal characters to be created (on the Windows end)? Wouldn't the copy operation either abort, or truncate, or replace the illegal characters?

In the 7-zip case, extracting from an archive is essentially a copy operation.
And for trailing (.), 7-zip substitutes a _ in its' place. (Might do similar with other illegal characters?)

My file manager will not allow creation of an illegally named file.
My download manager will... oh, not quite sure, maybe something like, may either truncate or silently remove (may depend on the particular character in the downloaded file name) illegal characters. (Yes, it can create long directory structures [easily > 260 chars, but with some limitations too - in which case it will require you to shorten the length prior to the download proceeding] that will thwart many Windows utilities, but that is relatively easy to overcome - after the fact.)
therube
 
Posts: 921
Joined: Mon Jan 18, 2016 6:23 pm

Re: Windows Illegal Character Help

Postby CliffyBoy » Tue Apr 21, 2020 5:27 pm

Thanks everyone for your responses.

RegexNinja,
I did review FileBoss and I am able to rename files individually. However, so far I haven't figured out how to do mass renaming. There doesnt seem to be any explicit function that references folder renames, only files. Im still messing with it trying to figure it out. I think you are correct that the explict illegal mass file renaming is slated for the next version cuz I dont see that in this current version. The good news is that mass folder/file renaming of illegal characters is possible and doable using WinRar (likely 7zip as well, I dont have that one). The procedure is just select folders/files with the characters, then send to archive. From inside the archive you can see that the files/folders still have the illegal character, then simply do an extraction and WinRar will push out the files/folders minus the illegal characters without issue. So ez its crazy! This is a very good solution since no addtional software purchase is needed. Thanks for the tip!
As far as the regex, I will test those after i finish all the renames.

Therube,
The way to visualize a file/folder with a trailing space is to try and rename it. The selection hightlighted will reveal a space after the file/folder name that you will be unable to change. Also the Windows system will throw an error telling you the file/folder is not found, and it will have a zero byte file size.
CliffyBoy
 
Posts: 24
Joined: Sun Apr 19, 2020 9:36 pm

Re: Windows Illegal Character Help

Postby trm2 » Tue Apr 21, 2020 5:49 pm

refers to Next version of Fileboss not recent - also this has been in development I believe since 2017 - so don't cross fingers.

As for illegal characters- don't. They are system reserved - Linux has them, Windows has them - they all have them just not the same ones.
You can circumvent Windows by renaming the files in Linux but once you get back to Windows, it will be problematic getting those files to work with
many programs. Also if you wanted to rename them back - good luck. There are ways but they are iffy.

More common is finding methods to rename after Chkdsk gets done with them or a bad data restore. But to force a rename?

Not recommended.

I also think that Fileboss is not talking about renaming files to illegal characters but renaming files with illegal characters. That I think is what the new version is about.
trm2
 
Posts: 155
Joined: Wed Jan 15, 2020 12:47 pm

Re: Windows Illegal Character Help

Postby RegexNinja » Wed Apr 22, 2020 2:46 am

Trm2,
I'm afraid I misled you on another post.. Our goal is to get rid of those illegal characters, lol.
I've seen this requested often, when ppl need to rename files on drives touched by other OS's.
So I'm always on the lookout for an app that can handle such renames automatically.

For anybody who's curious:
Apps that rely on Windows API's (99%) for file-handling, will always fail on names with illegal chars.
For apps that work independently of those API's, it depends on how the app's internal-handler is coded.
WinZip/7zip/FileBoss are some notable exceptions.. Always looking for more.

CliffyBoy,
Well, that's sort of good news.. I had high hopes the mass-renaming in FileBoss, only 1 at-at ime, huh?
Thanks for posting back with the WinZip solution to handle the mass-renaming.
I agree, it'd prob work in 7Zip as well.. Nice work!!

I'm curious, how did you go about finding the problem files/folders.. Was BRU helpful?
Again, thanks for posting back.. I'll definitely be referencing this post to others in the future.
No special software required!
RegexNinja
 
Posts: 134
Joined: Fri Feb 21, 2020 5:26 pm

Re: Windows Illegal Character Help

Postby Admin » Wed Apr 22, 2020 4:25 am

Will the WinRar / 7Zip method delete the original file name with the illegal chars? Or does it just create a new set of files without illegal characters?
We need to investigate if BRU can be modified to handle illegal chars. cheers
Admin
Site Admin
 
Posts: 1896
Joined: Tue Mar 08, 2005 8:39 pm

Next

Return to How-To