Hey Guys,
iam trying to write a little shellscript that simply does the following:
create symlink in one folder e.g.:
Zitat"/media/UUID/Series2013/"
called:
Zitat"Series with spaces in the title"
that points to:
Zitat"/media/UUID/Series/subdirectory/Series with spaces in the title"
the folder "subdirectory" can be one of the five following:
Zitat0-C
D-L
M-R
S-T
U-Z
If iam doing it manually with escaping characters by using "" the link gets created.
root@omv-nas:~# ln -s "/media/d3c21c66-af4b-41d4-b098-462e83fa641d/Serien/test 123" "/media/d3c21c66-af4b-41d4-b098-462e83fa641d/ASerien/test 123"
root@omv-nas:/media/d3c21c66-af4b-41d4-b098-462e83fa641d/ASerien# ls -l
insgesamt 0
lrwxrwxrwx 1 root root 22 3. Apr 17:05 Friends -> ../Serien/D-L/Friends/
lrwxrwxrwx 1 root root 35 3. Apr 17:08 How I Met Your Mother -> ../Serien/D-L/How I Met Your Mother
lrwxrwxrwx 1 root root 59 3. Apr 17:58 test 123 -> /media/d3c21c66-af4b-41d4-b098-462e83fa641d/Serien/test 123
The Links for Friends and How I Met Your Mother were created within /media/d3c21c66-af4b-41d4-b098-462e83fa641d/ASerien/, so i just pointed them the directory upwards to their respective directorys within Serien/subdirectory/...
However, if iam using a script like that, it does not escape the spaces correctly.: (yes it is in german, and yes atm it is just poiting to the directory "Series'")
#!/bin/sh
# Script zum hinzufuegen von Softlinks
cd /media/d3c21c66-af4b-41d4-b098-462e83fa641d/Serien/
ln -s "$@" /media/d3c21c66-af4b-41d4-b098-462e83fa641d/ASerien/$@
echo "Softlink fuer Serie $@ erfolgreich angelegt!"
Purpose of this script or the Softlinks is, that i have an extra share for the Series' that are actually running Episodes or iam "rerunning/watching" at the moment. (Much easier for Media Boxes just to need to scroll through some Series' and not all of them)
Can anybody help me how to correctly escape the spaces in that case?
And it would be nice if the Script would automatically detects the right folder for the Series, but that would'nt be neccessary, as i could simply use 5 scripts, one for each directory.
Greetings
David