Explorar el Código

Only chdir() for the quoted paths

Zachary Kotlarek hace 9 años
padre
commit
05b3751d8f
Se han modificado 1 ficheros con 6 adiciones y 3 borrados
  1. 6 3
      tvdup.sh

+ 6 - 3
tvdup.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 set failglob
+BASE="/mnt/media/TV"
 
-cd /mnt/media/TV
 declare -A seen
 while IFS= read -r -d '' lpath; do
 	count=0
@@ -27,9 +27,12 @@ while IFS= read -r -d '' lpath; do
 			continue
 		fi
 		seen["${id}"]=1
+
 		echo "Multiple matches for: ${id}" 1>&2
-		ls -lhtQ "${id}"*
+		short="`echo "${id}" | sed "s%^${BASE}/%%"`"
+		(cd "${BASE}" && ls -lhtQ "${short}"*)
+
 		sudo chattr -i "${id}"*
 		touch "${id}"*
 	fi
-done< <(find . -type f -path '*Season*' -name '[0-9]*.*' -print0)
+done< <(find "${BASE}" -type f -path '*Season*' -name '[0-9]*.*' -print0)