I have 10 images in the folder(1.jpg, 2.jpg, 3.jpg, ..., 10.jpg) and I want to copy only 5 images(1.jpg, 2.jpg, 4.jpg, 6.jpg, 8.jpg) into another folder. But I am getting this error.
`
Traceback (most recent call last):
File "/home/vkaps-lp-101/Desktop/Core Python
Code/19_Time_lapse/test.py", line 92,
in <module>
copytree(d, dst, symlinks = False, ignore = None,
copy_function = copy2)
File "/usr/lib/python3.8/shutil.py", line 555, in copytree
with os.scandir(src) as it:
ValueError: scandir: embedded null character in path
`
`
import os
import numpy as np
import shutil
from PIL import Image
import numpy as geek
arr = os.listdir('10_f/')
src = '10_f/'
dst = 'folder/'
arr.sort()
# print('arr: ', arr)
b = np.array(arr)
# print('b: ', b)
c = b.reshape(-1, 1)[::2].ravel()
print('c: ', c)
d = c.tobytes()
print(len(c))
# for file in d:
# print(file, end=' ')
# file = file.tobytes()
# print(type(file))
out_arr = geek.array_str(c)
# print ("The string representation of input array: ", out_arr)
# print(type(out_arr))
from shutil import copytree, ignore_patterns, copy2
copytree(d, dst, symlinks = False, ignore = None, copy_function =
copy2)
`
import glob
import os
import shutil
input_dir = 'C:/your/input/folder'
output_dir = 'C:/your/output/folder'
files = glob.glob(os.path.join(input_dir, '*.jpg'))
for f in files:
shutil.copy(f, output_dir)
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.