# Filenames
## Backup files
```sh
find . -name '~*' | rsync -nd --files-from=- . Archiv/BackupFiles
```
## Characters
While nextcloud supports (nearly) any file name, some OS are very restrictive.
Problematic: `~ " # % & * : < > ? / \ { | } $`
E.g. to replace ?, + and $ (remove -n to actually do something):
```sh
find . -depth -print0 | xargs -0 rename -n -e 's:[?]:FRAGEZ:g; s:[+]:PLUS:g; s:[\$]:DOLLAR:g;' \;
```
```sh
find . -depth -print0 | xargs -0 rename -n -e 's:[#]:⌗:g; s:["]:“:g; s:[~]:∼:g; s/[:]/COLON/g; s:[%]:PROZENT:g; s:[\&]:UND:g; s:[\*]:∗:g; s/[:]/∶/g; s:[<]:≺:g; s:[>]:≻:g; s:[\?]:⍰:g; s:[\+]:∔:g;' \;
find . -depth -print0 | xargs -0 rename -n -e 's:[|]:BAR:g; s:[{]:(:g; s:[}]:):g; s:[\$]:DOLLAR:g; s:[#]:⌗:g; s:["]:“:g; s:[~]:∼:g; s/[:]/COLON/g; s:[%]:PROZENT:g; s:[\&]:UND:g; s:[\*]:∗:g; s/[:]/∶/g; s:[<]:≺:g; s:[>]:≻:g; s:[\?]:⍰:g; s:[\+]:∔:g;' \;
find . -depth -print0 | xargs -0 rename -n -e 's:[\\]:BACKSLASH:g; s:[|]:BAR:g; s:[{]:(:g; s:[}]:):g; s:[\$]:DOLLAR:g; s:[#]:⌗:g; s:["]:“:g; s:[~]:∼:g; s/[:]/COLON/g; s:[%]:PROZENT:g; s:[\&]:UND:g; s:[\*]:∗:g; s/[:]/∶/g; s:[<]:≺:g; s:[>]:≻:g; s:[\?]:⍰:g; s:[\+]:∔:g;' \;
```
> Notes:
> : is defined twice.
> instead of | (BAR) could be ¦
In any case allowed are:
'a'...'z'
'A'...'Z'
'0'...'9'
'.'
'-'
'_'
As check if they are present:
```sh
find . -depth -print0 | xargs -0 rename -n -e 's:[^a-zA-Z0-9.-_]::g' \;
find . -depth -print0 | xargs -0 rename -n -e 's:[^a-zA-Z0-9.\-_äöüÄÖÜß/ (),⌗“∼∗∶≺≻⍰∔]::g' \;
find . -depth -name '*[^a-zA-Z0-9.\-_äöüÄÖÜß (),⌗“∼∗∶≺≻⍰∔]'
```
## Depth
Maximum allowed depth: 32
```sh
find . -type d -printf '%d %f\n' | sort -rn | awk '$1 > 31 {print;}'
```
## Max Files
Max Files per Folder: 512
```sh
find . -xdev -type d -exec sh -c 'echo "$(find "$0" | grep "^$0/[^/]*$" | wc -l) $0"' {} \; | sort -rn > list_of_files.txt
```
Remove the ones which are not problematic and cut the first line
```zsh
for d in `cat list_of_files.txt`
cd $d
for i in `seq 1 3`
do
mkdir $i
mv -- *(^/[1,500]) $i # move 500 files (^/ to exclude directories)
done
done
```
# Max Links
Maximum of internal links per folder: 3
Here is unclear to me what this actually means, I checked for:
```sh
find . -type s -or -iname '*.URL' -or -iname '*.webloc'
```
## Max Path Length
Max path length (inclusive subfolder and file name): 4096 - 1024(BLOB) = 3072 chars (getconf PATH_MAX)
```sh
find . | egrep '^.{3071,}$'
```
## Max Name Length
Folder or file names: 223 chars (getconf NAME_MAX)
```sh
find -exec basename '{}' ';' | egrep '^.{222,}$'
```
## Max File Size
Max file size can be configured from 256MB to 14GB
```sh
find . -xdev -type f -size +255M -print | xargs ls -lh | sort -k5,5 -h -r
```