I have a directory named STA. Within that directory are about 600 other directories that have the format hh:mm:ss (for example 00:01:34). Within each of these sub-directories should be three files. I also have a file, 'waveformlist', (contained within STA) which is a list of all of these sub-directories i.e.:
00:01:34
00:02:35
etc.
A lot of the sub-directories do not contain these three files and are instead empty. I want to run a C-shell script to go through every sub directory and check if it is empty. If it is empty I want to delete that sub directory from the main directory STA, and also remove that sub-directory name from the list 'waveformlist'.
Below is my script so far. It does not recognize when the sub-directory is empty or not and does not like the rm $dir line. Also, I do not know how to go and remove the sub-directory name from 'waveformlist'.
#!/bin/csh
echo "Enter name of station folder to apply filter to as 'STA' e.g. APZ:"
set ans = $<
cd $ans
set c=0
foreach dir (*:*)
if ("${c}" == 0) then
echo "Empty directory:" $dir
rm $dir
else
echo ${dir} "has files"
endif
end
I hope I have been clear enough.