質問編集履歴

3

修正

2018/05/23 11:53

投稿

sobue
sobue

スコア329

test CHANGED
File without changes
test CHANGED
@@ -78,7 +78,99 @@
78
78
 
79
79
  ```
80
80
 
81
+ ```java
81
82
 
83
+ package main;
84
+
85
+
86
+
87
+ import java.io.File;
88
+
89
+ import java.io.IOException;
90
+
91
+
92
+
93
+ import com.drew.imaging.jpeg.JpegMetadataReader;
94
+
95
+ import com.drew.imaging.jpeg.JpegProcessingException;
96
+
97
+ import com.drew.metadata.exif.ExifDirectoryBase;
98
+
99
+ import com.drew.metadata.exif.ExifSubIFDDirectory;
100
+
101
+
102
+
103
+ public class ExifUtil {
104
+
105
+
106
+
107
+ public static String getPhotoDate(File pictureFile) {
108
+
109
+ ExifDirectoryBase directory = null;
110
+
111
+ String year;
112
+
113
+ String month;
114
+
115
+ String day;
116
+
117
+ String hour;
118
+
119
+ String minute;
120
+
121
+ String second;
122
+
123
+ try {
124
+
125
+ directory = JpegMetadataReader.readMetadata(pictureFile).getFirstDirectoryOfType(ExifDirectoryBase.class);
126
+
127
+ } catch (JpegProcessingException e) {
128
+
129
+ // TODO 自動生成された catch ブロック
130
+
131
+ e.printStackTrace();
132
+
133
+ } catch (IOException e) {
134
+
135
+ // TODO 自動生成された catch ブロック
136
+
137
+ e.printStackTrace();
138
+
139
+ }
140
+
141
+
142
+
143
+ year = directory.getString(ExifSubIFDDirectory.TAG_DATETIME).toString().substring(0, 4) + "年";
144
+
145
+ month = directory.getString(ExifSubIFDDirectory.TAG_DATETIME).toString().substring(5, 7) + "月";
146
+
147
+ day = directory.getString(ExifSubIFDDirectory.TAG_DATETIME).toString().substring(8, 10) + "日";
148
+
149
+ hour = directory.getString(ExifSubIFDDirectory.TAG_DATETIME).toString().substring(11, 13) + "時";
150
+
151
+ minute = directory.getString(ExifSubIFDDirectory.TAG_DATETIME).toString().substring(14, 16) + "分";
152
+
153
+ second = directory.getString(ExifSubIFDDirectory.TAG_DATETIME).toString().substring(17, 19) + "秒";
154
+
155
+ String pDate = year + month + day + hour + minute + second;
156
+
157
+ return pDate;
158
+
159
+ }
160
+
161
+
162
+
163
+ }
164
+
165
+
166
+
167
+ ```
168
+
169
+ 使用jar
170
+
171
+ xmpcore-5.1.2.jar
172
+
173
+ metadata-extractor-2.9.1.jar
82
174
 
83
175
  上記のソースにフォルダごとに一意のファイル名を付けたいと思っています。
84
176
 

2

修正

2018/05/23 11:53

投稿

sobue
sobue

スコア329

test CHANGED
File without changes
test CHANGED
@@ -82,6 +82,6 @@
82
82
 
83
83
  上記のソースにフォルダごとに一意のファイル名を付けたいと思っています。
84
84
 
85
- 年月日時分秒まではファイル名のお約束として付けです。
85
+ 秒まで一致していると一意にならないめ対策が必要なのですがどうやったらいいかがわかりません
86
86
 
87
- どのようしたら、一意のファイル名なりまか?
87
+ フォルダごと番号を一意にしたいで

1

ファイルパス修正

2018/05/23 11:48

投稿

sobue
sobue

スコア329

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  public static void main(String[] args) {
16
16
 
17
- String path = "C:\Users\naoya\Desktop\2006_12_18";
17
+ String path = "写真のあるディレクトリ";
18
18
 
19
19
  mainProc(path);
20
20