I am working on a project that requires batch processing of a large number of image files. To keep things simple, I wrote a script that will create directories nand move files mto them based on user input.
My problem is now to understand directory traversal through a shell script.
I added this snippet at the end of the sorting script described above
dirlist=$(find $1 -mindepth 1 -maxdepth 1 -type d)
for dir in $dirlist
do
cd $dir
echo $dir
ls
done
When I launched it in the Pano2 folder, which has two internal folders, I always had an error
./dirTravel: line 9: cd: Pano2/05-15-2012-2: No such file or directory
However, after that I get a list of files from the specified directory.
What is the reason for the warning? If I add cd ../after ls, I will get a list of folders inside Pano2 /, but not the files themselves.
source
share