3

Here is what I prepared and where I got stuck:

find / \! -name "*[:alnum:]*" -type f -ls > ~/Desktop/files_not-allowed-char.txt

I actually want to list all files which include one of these characters:

\ / : * ? " < > |

The other way around: I want to list all files which have other characters in the name than:

[A-Z][a-z][0-9]äöüÄÖÜß_-.()#[]
or in other "words":
[:alnum:] and "äöüÄÖÜß_-.()#[]"

I hope I could clarify my wishes. I am entering unknown territory...

Thanks in advance!


Background info: I want to change from AFP to SMB but have to make sure that I rename all invalid file and folder names (e.g. invalid_Directory_Name./ ).

user4556274
  • 223
  • 1
  • 5
user2437272
  • 33
  • 1
  • 4

1 Answers1

2

Using ! in front of "[:alnum:]" will negate any file that has a character in [:alnum:] so it will only match file names which ONLY have non alphanumeric characters.

You could use a different regex to find punctuation find . -name "*[:punct:]" but that includes characters you don't care about. find . -name "*[\/:*?"<>|]*" should match anything with at least one of those characters in the brackets. (though you probably need to escape a few of them :) )

Joe
  • 1,043
  • 8
  • 11
  • This helped a lot... `find /volume1 -name "*[\+\{\;\"\\\=\?~\(\)\<\>\&\*\|\$]*" -ls -type f > /volume1/volume1-file_not-allowed-char.txt` is my solution. – user2437272 Sep 27 '16 at 16:54