ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

IDEA: Utility to handle files/folders with illegal characters

<< < (3/5) > >>

MilesAhead:
See if this answer is any help
http://stackoverflow.com/questions/1652483/convert-between-url-and-windows-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


MilesAhead:
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:
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.
-4wd (May 08, 2015, 08:37 AM)
--- End quote ---
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/questions/1652483/convert-between-url-and-windows-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
-MilesAhead (May 08, 2015, 09:37 AM)
--- End quote ---

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.-MilesAhead (May 08, 2015, 10:05 AM)
--- End quote ---
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:
However, I think I have more files and drives with similar problems. Maybe the easiest would be to reinstall Linux...
-def (May 11, 2015, 11:52 AM)
--- End quote ---

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/questions/20766574/batch-rename-files-on-a-shared-ntfs-to-windows-style-file-names

AbteriX:
Or use a Linux Live that has NTFS support. -MilesAhead (May 11, 2015, 01:57 PM)
--- End quote ---
Perhaps try mount -o check=r

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
--- End quote ---
From http://www.linuxquestions.org/questions/linux-newbie-8/filename-containing-a-question-mark-735617/

 

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version