Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running windows server 2003 and I need to find a way to mass rename folders that contains chinese characters. Basically I want to remove chinese characters but if I remove it then the folder name won't have a name so I need to replace it with some random 5 digit letter/numbers.

Any solutions?

share|improve this question
    
Windows may already have done so for you computerhope.com/issues/ch000209.htm – Andrew Lambert Oct 29 '12 at 6:42
    
@Amazed: Which ancient version of Windows are you talking about? :) – Karan Oct 29 '12 at 8:22
    
@Karan Every one that supports NTFS. – Andrew Lambert Oct 29 '12 at 14:56
    
@Amazed: So you're talking about the 8.3 short names? I doubt that sort of shortening is acceptable in this case, but it's up to the OP of course. – Karan Oct 29 '12 at 16:10
up vote 0 down vote accepted

You can try Ken Rename.

I first changed the settings to replace all illegal characters with underscores:

1

Next I selected the option to change the code page of the filenames from Unicode to Windows-1252. This replaced the Chinese characters with question marks, which, being wildcards and thus illegal filename characters in Windows, were in turn replaced by underscores:

2

In case this does not suffice and you really need it, there might be a way to replace the characters with random digits as well, but I didn't check.

share|improve this answer
    
I just noticed that there are a few folders that didn't get rename. Examples: code[Mokusa] R.MikaおっぱいCG集 [526015] code[Visual Biscuits]S.D. -_魔のウルラさんにひたすら_り取られちゃう系CG集- [525769] – Ruriko Oct 30 '12 at 4:20
    
No sure why this is happening TBH. Are those all valid Chinese characters? – Karan Oct 30 '12 at 18:17
    
it's actually japanese characters – Ruriko Oct 30 '12 at 23:56

You can use PowerShell:

Get-ChildItem -Recurse |
  ForEach-Object {
    $n = $_.BaseName -replace '[\p{IsCJKUnifiedIdeographs}]'
    while ($n -match '^\s*$' -or (Test-Path (Join-Path (Split-Path -Parent $_.FullName) $n)) {
      $n = -join(0..5|%{[char[]](65..90+97..122+48..57)|Get-Random})
    }
    Rename-Item $_.FullName ($n + $_.Extension)
  }

This removes all CJK Ideographs from the file name (you might need to extend the character class a bit with other blocks if necessary) and if it is empty afterwards or clashes with an existing name a random alphanumeric name will be generated.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .