Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 08, 2016, 10:13:31 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: Utility to handle files/folders with illegal characters  (Read 5455 times)

def

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 31
    • View Profile
    • Donate to Member
A Windows utility to rename and/or delete files/folders with illegal characters in their names (e.g. question marks etc.). On the internet, I've mostly found clumsy workarounds such as setting up a Linux VM, trying chkdsk /f, or even trying 8.3 names (if they are not disabled).

The only dedicated tool I have found in a quick web search is DelinvFile (have not tried it myself) which costs $31.95 (USD) and which seemingly offers to at least delete such files/folders (not sure about renaming).

Interesting challenge?

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,286
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #1 on: May 07, 2015, 02:53:35 PM »
Have you tried Unlocker

I'm just wondering how the files get created with illegal names in the first place.  It seems strange.

def

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 31
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #2 on: May 07, 2015, 03:08:44 PM »
Have you tried Unlocker
Just tried it. Doesn't work ("no locking handle found").

I'm just wondering how the files get created with illegal names in the first place.  It seems strange.
In my case it's a file and a folder on a USB drive, from a time when I experimented with Linux. At this time I only use Windows, thus I recognize how tedious such a file can be...

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,474
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #3 on: May 08, 2015, 01:27:51 AM »
Possibly Powershell?

Remove Invalid Characters from File Names

Though the problem remains of how to get the file from the filesystem before fixing it.
« Last Edit: May 08, 2015, 01:33:37 AM by 4wd »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,286
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #4 on: May 08, 2015, 05:43:32 AM »
Possibly Powershell?

Remove Invalid Characters from File Names

Though the problem remains of how to get the file from the filesystem before fixing it.

There are Linux win32 utilities that have bash shell with ls and rm commands.  I haven't used it in some time.  I'm not sure which is the latest or most friendly to Windows newer than XP.  Once the bash shell is running just use rm command to remove files and/or folders

http://www.cyberciti...folder-and-contents/

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,783
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #5 on: May 08, 2015, 07:05:06 AM »
There are Linux win32 utilities that have bash shell with ls and rm commands.
Cygwin ?

def

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 31
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #6 on: May 08, 2015, 07:13:04 AM »
There are Linux win32 utilities that have bash shell with ls and rm commands.  I haven't used it in some time.  I'm not sure which is the latest or most friendly to Windows newer than XP.  Once the bash shell is running just use rm command to remove files and/or folders

http://www.cyberciti...folder-and-contents/
I downloaded Cygwin but it couldn't delete the file in question:

How can I fix_repair a corrupted PDF file? - Super User.html                      
How can I fix_repair a corrupted PDF file? - Super User-Dateien

$ rm "How can I fix_repair a corrupted PDF file? - Super User.html"
rm: cannot remove ‘How can I fix_repair a corrupted PDF file? - Super User.html’: No such file or directory

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,286
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #7 on: May 08, 2015, 07:19:52 AM »
There are Linux win32 utilities that have bash shell with ls and rm commands.  I haven't used it in some time.  I'm not sure which is the latest or most friendly to Windows newer than XP.  Once the bash shell is running just use rm command to remove files and/or folders

http://www.cyberciti...folder-and-contents/
I downloaded Cygwin but it couldn't delete the file in question:

How can I fix_repair a corrupted PDF file? - Super User.html                      
How can I fix_repair a corrupted PDF file? - Super User-Dateien

$ rm "How can I fix_repair a corrupted PDF file? - Super User.html"
rm: cannot remove ‘How can I fix_repair a corrupted PDF file? - Super User.html’: No such file or directory

I would try ls using a pattern so that only the file(s) you wish to delete match.  Then use the same pattern with rm.  For example
ls -l How*


def

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 31
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #8 on: May 08, 2015, 07:44:33 AM »
I would try ls using a pattern so that only the file(s) you wish to delete match.  Then use the same pattern with rm.  For example
ls -l How*

$ ls -l
ls: cannot access How can I fix_repair a corrupted PDF file? - Super User-Dateien: No such file or directory
ls: cannot access How can I fix_repair a corrupted PDF file? - Super User.html: No such file or directory
total 19940148
----rwx---+ 1 def None    2304492 Dec 24  2007 9783827241993bsp.pdf
(several other files...)
-?????????? ? ?   ?             ?            ? How can I fix_repair a corrupted PDF file? - Super User.html
d?????????? ? ?   ?             ?            ? How can I fix_repair a corrupted PDF file? - Super User-Dateien
(several other files...)

$ ls -l How*
ls: cannot access How can I fix_repair a corrupted PDF file? - Super User.html: No such file or directory
ls: cannot access How can I fix_repair a corrupted PDF file? - Super User-Dateien: No such file or directory

$ rm -r How*
rm: cannot remove ‘How can I fix_repair a corrupted PDF file? - Super User.html’: No such file or directory
rm: cannot remove ‘How can I fix_repair a corrupted PDF file? - Super User-Dateien’: No such file or directory

Somehow even Cygwin chokes on this file name...

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,474
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #9 on: May 08, 2015, 08:37:02 AM »
Try running chkdsk.exe /f on the volume, it can sometimes fix these problems by removing the (illegally named) file.

If the file gets deleted, it might be reincarnated (with a new name) by looking at any filecheck.* that was created.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,286
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #10 on: May 08, 2015, 09:37:04 AM »
See if this answer is any help
http://stackoverflow...indows-filename-java

Edit:

The filename looks like it is created from a URL.  Somewhere on AHK forum I got this function

PathCreateFromURL( URL )
{
  if (! URL)
  return ""
 VarSetCapacity( fPath, Sz := 2084, 0 )
 DllCall( "shlwapi\PathCreateFromUrl" ( A_IsUnicode ? "W" : "A" )
     , Str,URL, Str,fPath, UIntP,Sz, UInt,0 )
 return fPath
}

If you pass in a string with the filename it should spit out an acceptable Windows filename or an empty string on error.

Edit: for example

URL := "file://c|MyFolder/yaddyadda.txt"
fname := PathCreateFromURL(URL)
MsgBox % fname


« Last Edit: May 08, 2015, 09:46:01 AM by MilesAhead »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,286
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #11 on: May 08, 2015, 10:05:19 AM »
You could go at it from the other direction.  Copy all files with Windows legal names you want to keep from the thumb drive to some other storage.  Format the thumb drive erasing all data.


def

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 31
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #12 on: May 11, 2015, 11:52:00 AM »
Try running chkdsk.exe /f on the volume, it can sometimes fix these problems by removing the (illegally named) file.

If the file gets deleted, it might be reincarnated (with a new name) by looking at any filecheck.* that was created.
I tried this, alas the drive (partition) is truecrypted, and chkdsk refuses working on it as another process (probably TrueCrypt) is accessing it, thus it insists on releasing the partition and subsequently chkdsk-ing it (who knows what that will do that to the partition?). Which is all the more surprising considering that according to the TrueCrypt documentation, using chkdsk should be possible on TrueCrypt volumes...

See if this answer is any help
http://stackoverflow...indows-filename-java

Edit:

The filename looks like it is created from a URL.  Somewhere on AHK forum I got this function

PathCreateFromURL( URL )
{
  if (! URL)
  return ""
 VarSetCapacity( fPath, Sz := 2084, 0 )
 DllCall( "shlwapi\PathCreateFromUrl" ( A_IsUnicode ? "W" : "A" )
     , Str,URL, Str,fPath, UIntP,Sz, UInt,0 )
 return fPath
}

If you pass in a string with the filename it should spit out an acceptable Windows filename or an empty string on error.

Edit: for example

URL := "file://c|MyFolder/yaddyadda.txt"
fname := PathCreateFromURL(URL)
MsgBox % fname

Well, these might help in the future. Interestingly, NTFS-3G (this Linux thingy that writes files to NTFS drives) also seems to have an option windows_names that should be default anyway, IMHO. Which it currently isn't, at least not in the Linux distro that I tried.

You could go at it from the other direction.  Copy all files with Windows legal names you want to keep from the thumb drive to some other storage.  Format the thumb drive erasing all data.
Yea, that's clearly possible.
However, I think I have more files and drives with similar problems. Maybe the easiest would be to reinstall Linux...!  ;D

Anyway, thanks for your efforts.  :)

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,286
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #13 on: May 11, 2015, 01:57:23 PM »
However, I think I have more files and drives with similar problems. Maybe the easiest would be to reinstall Linux...

Or use a Linux Live that has NTFS support.  You can mount the drive with the files that need to be renamed, as part of the live directory tree.  I would also search for a "one liner" in case someone has run into this before and posted the solution.  Some file pattern that would detect these types of filenames as input etc..

With all the machine dual booting Windows and Linux over the years there must be something canned out there somewhere.

Edit:  Looks like someone has attempted to use find Linux command to fix it up.  I don't know how successful it would be:

http://stackoverflow...ows-style-file-names
« Last Edit: May 11, 2015, 02:05:00 PM by MilesAhead »

AbteriX

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,115
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #14 on: May 12, 2015, 12:24:14 AM »
Or use a Linux Live that has NTFS support.
Perhaps try mount -o check=r

Quote
check=value
Three different levels of pickyness can be chosen:

r[elaxed]
Upper and lower case are accepted and equivalent, long name
parts are truncated (e.g. verylongname.foobar becomes very-
long.foo), leading and embedded spaces are accepted in each
name part (name and extension).

n[ormal]
Like "relaxed", but many special characters (*, ?, <, spaces,
etc.) are rejected. This is the default.

s[trict]
Like "normal", but names may not contain long parts and special
characters that are sometimes used on Linux, but are not
accepted by MS-DOS are rejected. (+, =, spaces, etc.)

The above is a quote out of the `mount` man page; I'm not familiar with CIFS but is it possible
 the default option setting for this mount option is causing the problem?
Maybe mounting with check=relaxed option would get around it.

Sasha

EDIT - PS, this option is for FAT, by the way; I forgot to mention
From http://www.linuxques...uestion-mark-735617/

 

x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 679
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #15 on: June 19, 2015, 05:09:19 AM »
Would be interested in knowing if SetACL Studio will work for this. It has a 30 day trial that ought to give you enough time to try it.
vi vi vi - editor of the beast

def

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 31
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #16 on: June 19, 2015, 05:27:14 PM »
Would be interested in knowing if SetACL Studio will work for this. It has a 30 day trial that ought to give you enough time to try it.
Probably not, as it's not a permission/security problem, although I have not tested this particular tool. Generally, when tools try to delete my test file they complain that there (supposedly) is no such file. Thanks for your suggestion, though.

However, I do have tested a bunch of deletion/renaming tools suggested on the internet. None worked.  :-\  :D

Most problems with "illegal" characters are related to exceeding the Windows file/path name length limits or funny symbols from Unicode file names (and missing fonts). As stated above, the chkdsk trick doesn't work for me. I have even tried to delete the whole containing folder, but no luck.

The only option seems to be the special tool DelinvFile, but I think $31.95 (USD) is a bit much...

Anyway, in the meantime I have reinstalled Linux (not just because of this problem, btw), so I will remove the files in question bit by bit.

Concluding I would like to say thanks to you all for your kind help. Feel free to suggest more solutions, maybe they can help other users with the same problem, although I personally will use Linux to remove all problematic files left. Thanks again.  :Thmbsup:

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,474
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #17 on: June 19, 2015, 08:08:57 PM »
However, I do have tested a bunch of deletion/renaming tools suggested on the internet. None worked.  :-\  :D

Reminds of when I had the same problem about 20 years ago, I had to write a program to rename/delete files that Windows wouldn't touch.

However that was when Windows 3.1 and FAT32 were still the norm.

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,100
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #18 on: June 21, 2015, 12:42:28 PM »
If you still have a 32-bit Windows OS, then I would suggest to download and use PortableLinux. Because then you can run Windows and Linux (Ubuntu) both at the same time. Whatever file gives you problems in on one OS, might not be problematic in the other as Windows and Linux have a different set of illegal characters that can be used with file names.

Too bad PortableLinux only works with 32-bit versions of Windows...the software (co-linux) that allows Linux to run besides Windows is 32-bit only and doesn't look like it is going to be fixed any time soon. Having said that, I personally have tried and tested PortableLinux successfully with Windows 2000, Windows XP, Windows7 and Windows 8.


Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,091
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #19 on: June 22, 2015, 09:41:30 AM »
I don't understand why "def" not yet have tested SetACL Studio https://helgeklein.com/setacl-studio/ - his "IDEA" is clearly not that easy to bring alive.

--------------

Quote
how to delete this empty file?
Try this - download SetACL Studio (which has a 30 day free trial) and navigate to the folder and see exactly what's there. This is useful software -
- "useful software"; you can say that again! It didn't ask any questions, but deleted the empty file just like it would have deleted any other file. BRAVO! Thank you, x16wda,   :Thmbsup: 
(but of course, normal price is €90 - so it should be able to do a lot more than those freeware apps)

Try SetACL Studio https://helgeklein.com/setacl-studio/

def

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 31
    • View Profile
    • Donate to Member
Re: IDEA: Utility to handle files/folders with illegal characters
« Reply #20 on: June 22, 2015, 03:13:19 PM »
I don't understand why "def" not yet have tested SetACL Studio https://helgeklein.com/setacl-studio/ - his "IDEA" is clearly not that easy to bring alive.

--------------

Quote
how to delete this empty file?
Try this - download SetACL Studio (which has a 30 day free trial) and navigate to the folder and see exactly what's there. This is useful software -
- "useful software"; you can say that again! It didn't ask any questions, but deleted the empty file just like it would have deleted any other file. BRAVO! Thank you, x16wda,   :Thmbsup: 
(but of course, normal price is €90 - so it should be able to do a lot more than those freeware apps)

Try SetACL Studio https://helgeklein.com/setacl-studio/


Yea, now I'm feeling guilty.  :-[

There are several reasons why I didn't test it (which are my own faults - not saying that SetACL Studio was bad in any way).

Firstly, I underestimated the work that would be required for programming this by a huge margin (hence I suggested it as a Coding Snack which was clearly a mistake). Secondly, I have tried to find freeware instead of payware for a task that I'd probably only need once in my life. Thirdly, after trying out several freeware tools that failed on this task, I was sure that any tool that didn't explicitly advertise "can handle file names with illegal characters" is not worth a try. Fourthly, SetACL Studio gave the impression (to me, at least) that it has only something to do with security permissions and not file names. Fifthly, SetACL Studio is payware - now, I'm not generally opposed to paying for software, but if I'd pay for a lot of features that I don't need (or that I don't even understand, for that matter), then I'm being reluctant. And sixthly, the problem wasn't that urgent to begin with, i.e. if no easy free/cheap solution comes about, reinstalling Linux is good enough for me.

Sorry for my ambiguous stance on this and, again, thanks for all your input. It's nice to know that according to Curt, SetACL Studio works for such files.  :)