IDEA: Utility to handle files/folders with illegal characters - DonationCoder.com
Welcome Guest.   Make a donation to an author on the site May 23, 2015, 08:27:11 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Your Support Funds this Site: View the Supporter Yearbook.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: IDEA: Utility to handle files/folders with illegal characters  (Read 798 times)
def
Participant
*
Posts: 27

View Profile Give some DonationCredits to this forum member
« on: May 07, 2015, 01:57:27 PM »

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?
Logged
MilesAhead
Supporting Member
**
Posts: 5,693



View Profile WWW Give some DonationCredits to this forum member
« 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.
Logged

def
Participant
*
Posts: 27

View Profile Give some DonationCredits to this forum member
« 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...
Logged
4wd
Supporting Member
**
Posts: 3,778



"This could get messy ..."

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« 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 » Logged

I do not need to control my anger ... people just need to stop pissing me off!
MilesAhead
Supporting Member
**
Posts: 5,693



View Profile WWW Give some DonationCredits to this forum member
« 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.biz/...rm-a-folder-and-contents/
Logged

Ath
Supporting Member
**
Posts: 2,437



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« 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 ?
Logged

Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)
def
Participant
*
Posts: 27

View Profile Give some DonationCredits to this forum member
« 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.biz/...rm-a-folder-and-contents/
I downloaded Cygwin but it couldn't delete the file in question:

[copy or print]
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
Logged
MilesAhead
Supporting Member
**
Posts: 5,693



View Profile WWW Give some DonationCredits to this forum member
« 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.biz/...rm-a-folder-and-contents/
I downloaded Cygwin but it couldn't delete the file in question:

[copy or print]
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*

Logged

def
Participant
*
Posts: 27

View Profile Give some DonationCredits to this forum member
« 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*

[copy or print]
$ 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...
Logged
4wd
Supporting Member
**
Posts: 3,778



"This could get messy ..."

see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« 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.
Logged

I do not need to control my anger ... people just need to stop pissing me off!
MilesAhead
Supporting Member
**
Posts: 5,693



View Profile WWW Give some DonationCredits to this forum member
« Reply #10 on: May 08, 2015, 09:37:04 AM »

See if this answer is any help
http://stackoverflow.com/...and-windows-filename-java

Edit:

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

[copy or print]
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

[copy or print]
URL := "file://c|MyFolder/yaddyadda.txt"
fname := PathCreateFromURL(URL)
MsgBox % fname


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

MilesAhead
Supporting Member
**
Posts: 5,693



View Profile WWW Give some DonationCredits to this forum member
« 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.

Logged

def
Participant
*
Posts: 27

View Profile Give some DonationCredits to this forum member
« 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.com/...and-windows-filename-java

Edit:

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

[copy or print]
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

[copy or print]
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...!  Grin

Anyway, thanks for your efforts.  smiley
Logged
MilesAhead
Supporting Member
**
Posts: 5,693



View Profile WWW Give some DonationCredits to this forum member
« 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.com/...-windows-style-file-names
« Last Edit: May 11, 2015, 02:05:00 PM by MilesAhead » Logged

AbteriX
Charter Honorary Member
***
Posts: 1,076


Member #520

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« 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.linuxquestions...g-a-question-mark-735617/

 
Logged

Greetings, Stefan.
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.049s | Server load: 0.11 ]


Share on Facebook
submit to reddit