I'm working on a project that requires batch processing of a large number of image files. To make things easier, I've written a script that will create n
directories and move m
files to them based on user input.
My issue is to now understand directory traversal via shell script.
I've added this snippet at the end of the sort 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 ran it inside a Pano2 folder, whcih contains two inner folders, I always got an error
./dirTravel: line 9: cd: Pano2/05-15-2012-2: No such file or directory
However, after that, I get the file listing from specified directory.
What is the reason behind the warning? If I add cd ../
after ls
I get the listing of the folders inside Pano2/, but not the files themselves.