Skip to content
This repository was archived by the owner on May 20, 2022. It is now read-only.

Commit 206a8b2

Browse files
committed
feat: remove file
1 parent ee4b5c9 commit 206a8b2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

fops/fops.py

100644100755
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,25 @@
66
# rm:cmd,file_pattern:string
77
# -------------------------------------------- #
88

9-
import glob
109
import sys
1110
import os
11+
import re
1212

1313

1414
def remove_by_file_pattern(args: list):
1515
if len(args) < 1:
1616
print('missing file pattern')
1717
return
1818
file_pattern = args[0]
19-
for filename in glob.glob(file_pattern):
20-
os.remove(filename)
19+
for (dirpath, dirnames, filenames) in os.walk('.'):
20+
for filename in filenames:
21+
path = '%s%s%s' % (dirpath, os.path.sep, filename)
22+
if re.search(file_pattern, path):
23+
print('remove file %s' % path)
24+
os.remove(path)
2125

2226

27+
print(sys.argv)
2328
for arg in sys.argv[1:]:
2429
cmd_arg = str.split(arg, ',')[1:]
2530

0 commit comments

Comments
 (0)