In the use of other people's Code, in order not to retain the file head copyright information, need to delete one by one, time-consuming and laborious,
Write a script that simply clears the header copyright information for all files in the directory.
#-*-Coding:utf8-*-
'
Delete the Java file header's Copyright Annotation
package Section
'
import OS
import SYS
def Delheader (filepath):
if Os.path.exists (filepath):
file = open (filepath)
lines = File.readlines ()
Beforetag = True
writer = open (filepath, ' W ') for line in
lines:
if ' package ' on line:
Beforetag = Fa LSE
If Beforetag = = False:
writer.write (line)
if __name__ = ' __main__ ':
path= ' f:\\space\\xxx\\ src '
list = Os.walk (path, True) for
dir-list:
files = dir[2] for
file in files:
if '. Java ' in File:
filepath = Os.path.join (dir[0], file)
print filepath
delheader (filepath)
PRINT ' Complete!!!!! !!!!!!!!!!'