Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To delete folder starting with a same starting characters

I need to delete folders in a folder in one shot, and this folders start with a common name, but does not end with. So any command with del/rm to do this? I tried with wildcards but that didn't work.

c:\temp> rmdir hello* --- directories with starting charecters as 'hello', didn't work

c:\temp> rmdir hello*.* --- didn't work

like image 351
Srikanth Yadake Avatar asked May 21 '13 09:05

Srikanth Yadake


People also ask

How do I delete all files from a certain type?

You can do this using the Windows GUI. Enter "*. wlx" in the search box in explorer. Then after the files have been found, select them all (CTRL-A) and then delete using the delete key or context menu.

How do you delete a file starting with letter in Linux?

You can use standard UNIX or Linux rm command to delete a file name starting with - or -- . All you have to do is instruct the rm command not to follow end of command line flags by passing double dash -- option before -foo file name.

How do I remove a directory from the start in Linux?

Note: If you want to remove a directory whose name starts with a hyphen (-), use the rm -- [directory name] or rm ./[directory name] syntax. Use the -r flag to delete a directory that contains subdirectories and files. The -i option displays a prompt asking you to confirm directory removal.


2 Answers

From the command line:

for /d %i in (hello*) do rd "%i"

In a batch file:

for /d %%i in (hello*) do rd "%%i"
like image 181
Jcl Avatar answered Nov 15 '22 15:11

Jcl


Try this - remove the echo if it works the way you expect it.

for /d %%a in (hello*) do echo rd /s /q "%%a"

change all %%a to %a to execute it from the command line.

like image 41
foxidrive Avatar answered Nov 15 '22 15:11

foxidrive