
scripts for Synology DSM
How do I run scripts from Synology Task Scheduler and how do I create scripts?
Click here for instructions how to create scripts and run those scripts from the Synology Task Scheduler in Control Panel.
Warning
Warning: always test scripts in a testing environment before usage, use at your own risk
Find files and directories with a certain length
Because of full path name limitations in Synology Drive Client and File Systems like Windows File system you can check on your NAS if files and directories exists which are longer than the limitation. When full path names are longer than the limit files and directories will not be synchronise via Synology Drive Client to the Windows file system.
Script:
# SET VARIABLES
DIR=”/volume1/Test folder/”
TH=254
# find “$DIR” -mindepth 1 -print0
# -mindepth 1 skips the directory itself and starts at its children.
# -print0 prints each matched path followed by a NUL byte, so filenames with spaces/newlines are handled safely.
# Iterate each path safely
# | xargs -0 -I{} sh -c ‘ …
# -0 tells xargs to split on NUL bytes (matching find -print0).
# -I{} runs the inner sh -c command once per {} (per path).
# For each path, compute its length and filter Inside the single quotes:
# p=”{}”;
# stores the current path into variable p.
# l=${#p};
# computes the character length of the string in p (for a normal byte-string; bash-style ${#var}).
# [ “$l” -ge “‘”$TH”‘” ] && printf “%s\t%s\n” “$l” “$p”
# test: if l >= TH then
# printf “%s\t%s\n” “$l” “$p”
# prints: <length>\t<full_path> on one line.
# Sort results by length descending
# | sort -nr
# -n: numeric sort
# -r: reverse (largest first)
find “$DIR” -mindepth 1 -print0 | xargs -0 -I{} sh -c ‘p=”{}”; l=${#p}; [ “$l” -ge “‘”$TH”‘” ] && printf “%s\t%s\n” “$l” “$p”‘| sort -nr
Synology Drive Client Log file
- On Windows check the daemon.log yourself at %localappdata%\SynologyDrive\log and search for keywords like “skip”, “too long”, “exceed”, or “limit”


