open(GETDIR, "cd |"); while() { chomp; $currentDir = $_; } open(DODIR, "dir /b /s|"); while() { chomp; $pathRemoved = $_; $pathRemoved =~ s/$currentDir//i; print $pathRemoved; }