What I want it to do is to process all sub folders and files in the given folder, what it does is do the 1st sub folder only
I've added extra echo's to check the loop status
---------------cut---------------
Code: Select all
in=$1
cd "$in"
out="./burn"
pwd=$PWD
echo "PWD $pwd"
for D in ./*; do
#test for folders
if test -d "$D"; then
echo "Loop = $loop D=$D" "folder yes"
cd "$D"
echo "Processing $D"
p1=${D##*/}
. sub=1
out1="$out/${pwd##*/}/$p1"
else
out1="$out/${pwd##*/}"
echo "$D not a folder"
fi
done
now sending it to a folder with 2 sub folders it is only seeing the first and claims the 2nd isn't a folder.
hairybiker@octo:~/temp$ ./test.sh test
PWD /home/hairybiker/temp/test
Loop = 0 D=./1 folder yes
Processing ./1
D=./1 p1=1 pwd=/home/hairybiker/temp/test ./burn//test/1 Loop=1 sub=1
in=test pwd=/home/hairybiker/temp/test D=./1 sub=1
./2 not a folder
D=./2 p1=1 pwd=/home/hairybiker/temp/test ./burn//test Loop=2 sub=1
in=test pwd=/home/hairybiker/temp/test D=./2 sub
test contains 2 sub folders 1 & 2
Also used [ -d "$D" ] and [[ -d "$D" ]] with same result.
edited for clarity.