I have a question: Is there any tutorial or way I could create a batch file that scans the folder that it's in, and then prompts you with an option of whether to delete any (C++, for example) files that don't begin with a command line, e.i. doesn't start with "//Start command line". Any ideas?

I have a question: Is there any tutorial or way I could create a batch file that scans the folder that it's in, and then prompts you with an option of whether to delete any (C++, for example) files that don't begin with a command line, e.i. doesn't start with "//Start command line". Any ideas?

for file in *
do
 read line < "$file"
 case $line in
   //Start\ command\ line*) ;;
   *) printf "Delete $file? "
      read reply
      case $reply in
        y|Y) rm "$file" ;;
      esac
      ;;
 esac
done
commented: Very good, lacks explanation. 4/5 stars. +0

Thanks! But can you explain how this works, what i should do? Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.