0

I use Dreamweaver to upload the web page to my site, it bring a folder called _note to everywhere in my site. I would like to ask how can I loop in the directory(/home/user/htdocs) to find the folder _note and delete it?

2 Answers2

3

Assuming you have a shell on the webserver, this command would do it:

find /home/user/htdocs -type d -name _note -exec rm -rfv "{}" \;

However I would be more careful then that. I would start by doing this to get a list and make sure its good:

find /home/user/htdocs -type d -name _note -exec echo "'{}'" \; > file.txt

Then review the file and if its all good:

cat file.txt | xargs rm -fvr 

That way you can catch errors before you delete critical files.

n8whnp
  • 1,326
  • Very useful of the information, btw what is "{}" in the command line? – Charles Yeung Apr 18 '11 at 04:51
  • the {} puts each result of the find command in the command you are running with the -exec flag. So in the first example, I search for all directories named _note and then execute the command rm -rfv the directory name. I add quotes, so that if you have a directory like: Files / Folders ... it does not try to remove /. – n8whnp Apr 18 '11 at 05:31
0

You can use lftp with rm -r to recursively remove a folder/file pattern/name. I think there is command line version of lftp for Windows that you can download and install.

coredump
  • 12,771