Page 1 of 1 1
Topic Options
#210291 - 2015-05-27 04:42 PM Remove Special Characters (Windows)
Valentim Offline
Fresh Scripter

Registered: 2010-01-04
Posts: 46
Loc: Brazil, PE, Recife
rename windows files and remove special characters of names.

I have a text file with all file names, but some files have a special characters like ":" or "?" i need remove this characters to windows accept new name of file.

Character list not supported by Windows: \ / : * ? " < > |

Question: How can I remove these special characters before you rename the files? What function or UDF can I use?
_________________________

Top
#210294 - 2015-05-27 08:06 PM Re: Remove Special Characters (Windows) [Re: Valentim]
Valentim Offline
Fresh Scripter

Registered: 2010-01-04
Posts: 46
Loc: Brazil, PE, Recife
I managed to solve, thought it would be more complicated, I only needed think more.

 Code:
Function StringReplace($String, $Search ,$Replace)
  $StringReplace = Join(Split($String, $Search), $Replace)
EndFunction

$aChars = Split('\ / : * ? " < > | !',' ')
For Each $char In $aChars
  $File = StringReplace($File, $char, "")
Next
_________________________

Top
#210296 - 2015-05-27 08:47 PM Re: Remove Special Characters (Windows) [Re: Valentim]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
Newer versions of Kix also have REPLACE as a built in function.
_________________________
(... better days ahead)

Top
#210298 - 2015-05-28 05:36 AM Re: Remove Special Characters (Windows) [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Yea, like Allen said. You could simplify it even more like so...

 Code:
$aChars = Split('\ / : * ? " < > | !',' ')
For Each $char In $aChars
  $File = Replace($File, $char, "")
Next

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.055 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org