echo "~~~~~~~~~~~~~Welcome to Ilya's File Program v1.0!~~~~~~~~~~~~"
while(1)
printf "\n\n"
cat menu.txt #Loads up the menu
printf "\n"
printf "\nENTER YOUR SELECTION>"
set input = $< #Asks for user selection
printf "\n"
if ($input == 'A' || $input == 'a') then #Find file in a directory case
echo "You have chosen to search for a file."
printf "Please Enter the File's Directory name>"
set directory = $<
if ($directory != "") then
echo "not null"
endif
#while ($directory != "" && !(-e $directory)) #Keep prompting until the user types a correct folder
while (1)
if ($directory != "") then
if (-e $directory) then
echo "breaking"
break;
echo "post breaking"
else if ($directory == 'Q' || $directory == 'q') then #Or give up if they cannot remember and exit
echo "Exiting Program...We will miss you! :(..."
exit(0)
endif
endif
echo "Directory $directory Does not Exist!"
printf "Please Enter the File's Directory name or Q to Exit program>"
set directory = $<
end
printf "\nPlease Enter the File name you wish to search for>"
set nonomatch #This is a CRITICAL piece which prevents set: no match errors
set filename=$<
printf "\n\n------------------------Searching for filename [$filename] in directory [$directory]----------------------------\n\n"
find $directory -name "$filename" -type f -print | xargs ls -l #Check files
find $directory -name "$filename" -type d -print | xargs ls -ld #Check directories
printf "\n\n--------------------Finished Searching for filename [$filename] in directory [$directory]-----------------------\n\n"
else if ($input == 'B' || $input == 'b') then
echo "You have chosen to calculate a file's length."
else if ($input == 'C' || $input == 'c') then
echo "You have chosen to find files of length 0."
else if ($input == 'D' || $input == 'd') then
echo "You have chosen to create backup files."
else if ($input == 'E' || $input == 'e') then
echo "Exiting Program...We will miss you! :(..."
exit(0)
else
echo "None of these choices match [$input]! Please type letters A through E"
endif
end