Jump to content

Recommended Posts

Posted

I have a problem that when adding the files that have some special character type # in the name they do not appear in the list I wanted these special characters to be removed when showing the name in the list can anyone help?

 

$ lista_pastas = _StringExplode ($ lista_pastas, "#", 0)
    
_ArraySort ($ lista_pastas, 1,1,1) 
$ conta_cds = UBound ($ lista_pastas) 
$ total_cds = $ conta_cds - 1 
$ qtde_casas = StringLen ($ total_cds) 
If $ qtde_casas <2 Then $ qtde_casas = 2
    If $ total_cds> = 1 Then 
    selecionar_cd ($ lista_pastas [1], 1) 
Else 
    MsgBox (4096, "ERRO!", "Não foram encontrados cd's no catálogo indicado!", 3) 
    Sair 
EndIf

  • Developers
Posted (edited)

Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states:

  Quote

Share your cool AutoIt scripts, UDFs and applications with others.


Do not post general support questions here, instead use the AutoIt Help and Support forums.

Expand  

Moderation Team

ps: This was the second time, so please post in the correct support forum from here on!

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)

I use the following code to remove invalid characters from a filename with an underscore:

; Replace invalid characters from filename with underscore. When $iFlags = 1 then space won't be replaced
$sFName = (BitAND($iFlags, 1) = 1) ? (StringRegExpReplace($sFName, '[\/:*?"<>|]', '_')) : (StringRegExpReplace($sFName, '[ \/:*?"<>|]', '_'))

Edit (4. April 2022):
As we are talking about file- and foldernames "\" should be removed as well (according to user p4sCH): 

; Replace invalid characters from filename with underscore. When $iFlags = 1 then space won't be replaced
$sFName = (BitAND($iFlags, 1) = 1) ? (StringRegExpReplace($sFName, '[\\\/:*?"<>|]', '_')) : (StringRegExpReplace($sFName, '[ \\\/:*?"<>|]', '_'))

The "solution" above removes invalid characters but the best solution would be to have a list of valid characters and remove everything else 😉 

Edited by water

My UDFs and Tutorials:

  Reveal hidden contents

 

  • 3 weeks later...
Posted

Hi

small section of a script to cleanup filenames:

$RegExKickNonAscii = "(?i)([^a-z0-9-_])" ; all but a-z0-9-_ forbidden

[...]
$FileNameWithExt = StringTrimLeft($ZipArchiv, StringInStr($ZipArchiv, "\", 0, -1))
$FileExt = StringTrimLeft($FileNameWithExt, StringInStr($FileNameWithExt, ".", 0, -1))
$FileName = StringLeft($FileNameWithExt, StringInStr($FileNameWithExt, ".", 0, -1) - 1)
$FileNameAsciiClean = StringRegExpReplace($FileName, $RegExKickNonAscii, "") & "." & $FileExt ; replace-with = "" means "kick" not wanted chars.
[...]

 

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Posted
  On 12/14/2020 at 12:54 PM, rudi said:

$RegExKickNonAscii = "(?i)([^a-z0-9-_])" ; all but a-z0-9-_ forbidden

Expand  

Good but won't work for people whose language use extra ASCII characters, leave alone most of Unicode. Remember most humans on Earth don't use a latin alphabet.

  Reveal hidden contents

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted (edited)

@jchd the OP mentioned: "...I wanted these special characters to be removed ..."

isn't it?

Exactly this was my task as well, for  the script I took these lines from: simply kick all non ASCII chars (ftp server url conformity)

For me it's the German Umlauts "äöüÄÖÜ" and the beautiful "ß"

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...