I can't seem to be able to escape these special characters - *. I'm trying to copy some files using a Python script with the following line
subprocess.call(r"mkdir E:\CONTENT\Full1",shell=True)
subprocess.call(r"copy","E:\DATA FOR CONTENT\*.*","E:\CONTENT\Full1",shell=True)
subprocess.call(r"fsutil file createnew ","E:\CONTENT\versionfile.txt","6500000",shell=True)
But I get the following error at the 2nd line
Traceback (most recent call last):
File "basic1.py", line 9, in <module>
subprocess.call(r"copy","E:\DATA FOR CONTENT\*.*","E:\CONTENT\Full1",shell=True)
File "C:\Python34\lib\subprocess.py", line 537, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Python34\lib\subprocess.py", line 767, in __init__
raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer
Also I hate passing it using the CSV Style ("arg1","arg2"...). Is there any way of passing it as a raw string?
subprocess.call(["copy", r"E:\DATA FOR CONTENT\*.*", r"E:\CONTENT\Full1"], shell=True)
Better don't do this via subprocess. Believe me it's a bad idea.
For simple filesystem copy operations take a look on python shutil module .
For creating new directories use os.makedirs .
For creating files of certain size see this answers .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.