teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

新しいコードとエラーメッセージを記載いたしました。

2020/11/04 20:51

投稿

emsky
emsky

スコア2

title CHANGED
File without changes
body CHANGED
@@ -21,6 +21,27 @@
21
21
 
22
22
  IsADirectoryError: [Errno 21] Is a directory: './data2/.ipynb_checkpoints'
23
23
 
24
+ Errorの追記
25
+ --SOM--
26
+ FileNotFoundError Traceback (most recent call last)
27
+ <ipython-input-8-68c047b322c4> in <module>
28
+ 2 os.makedirs(f"./data2_group5/{label}", exist_ok=True)
29
+ 3 if os.path.isfile(path):
30
+ ----> 4 shutil.copyfile(f"./data2/{path.replace(' .jpg', ' ')}", f"./data2_group5/{label}/{path.replace(' .jpg', ' ')}")
31
+ 5 print(label, path)
32
+
33
+ /anaconda3/lib/python3.7/shutil.py in copyfile(src, dst, follow_symlinks)
34
+ 119 else:
35
+ 120 with open(src, 'rb') as fsrc:
36
+ --> 121 with open(dst, 'wb') as fdst:
37
+ 122 copyfileobj(fsrc, fdst)
38
+ 123 return dst
39
+
40
+ FileNotFoundError: [Errno 2] No such file or directory: './data2_group5/1/1_001.jpg'
41
+ --EOM--
42
+
43
+
44
+
24
45
  ```
25
46
 
26
47
  for label, path in zip(labels, os.listdir('./data2')):
@@ -28,6 +49,14 @@
28
49
  shutil.copyfile(f"./data2/{path.replace(' .jpg', ' ')}", f"./data2_group2/{label}/{path.replace(' .jpg', ' ')}")
29
50
  print(label, path)
30
51
 
52
+ --SOM--
53
+ for label , path in zip(labels, os.listdir('./data2' )) :
54
+ os.makedirs(f"./data2_group5/{label}", exist_ok=True)
55
+ if os.path.isfile(path):
56
+ shutil.copyfile(f"./data2/{path.replace(' .jpg', ' ')}", f"./data2_group5/{label}/{path.replace(' .jpg', ' ')}")
57
+ print(label, path)
58
+ --EOM--
59
+
31
60
  ```ここに言語名を入力
32
61
  Python 3.7.6
33
62
  Anaconda Navigator