|
|
|
|
@ -8,11 +8,7 @@ import java.util.Date;
|
|
|
|
|
public class FileMove {
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
/*
|
|
|
|
|
FileMove.makeDir();
|
|
|
|
|
|
|
|
|
|
FileMove.makeDirSub();
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
FileMove.copyData();
|
|
|
|
|
}
|
|
|
|
|
@ -20,26 +16,25 @@ public class FileMove {
|
|
|
|
|
public static void copyData() {
|
|
|
|
|
try {
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); //년월일 표시
|
|
|
|
|
SimpleDateFormat sdf_4 = new SimpleDateFormat("yyyy");
|
|
|
|
|
//dateFormat = new SimpleDateFormat("yyyyMM"); //년월 표시
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf_4 = new SimpleDateFormat("yyyy");
|
|
|
|
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cal.set ( 2019, 12-1, 31 ); //종료 날짜 셋팅
|
|
|
|
|
String endDate = dateFormat.format(cal.getTime());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cal.set ( 2016, 1-1, 1 ); //시작 날짜 셋팅
|
|
|
|
|
String startDate = dateFormat.format(cal.getTime());
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
String startDate = dateFormat.format(cal.getTime());
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
String pathOrg = "E:\\혼잡_센터_이미지 백업\\DOTR"; //폴더 경로
|
|
|
|
|
String path = "E:\\혼잡_센터_이미지 백업\\New"; //폴더 경로
|
|
|
|
|
while(!startDate.equals(endDate)){ //다르다면 실행, 동일 하다면 빠져나감
|
|
|
|
|
while(!startDate.equals(endDate)){ //다르다면 실행, 동일 하다면 빠져나감
|
|
|
|
|
if(i==0) { //최초 실행 출력
|
|
|
|
|
System.out.println(dateFormat.format(cal.getTime()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startDate = dateFormat.format(cal.getTime()); //비교를 위한 값 셋팅
|
|
|
|
|
// 1호터널
|
|
|
|
|
copyFile(String.format("%s\\\\%s\\\\01\\\\IMAGE", pathOrg, startDate)
|
|
|
|
|
@ -48,11 +43,11 @@ public class FileMove {
|
|
|
|
|
// 3호터널
|
|
|
|
|
copyFile(String.format("%s\\\\%s\\\\03\\\\IMAGE", pathOrg, startDate)
|
|
|
|
|
, String.format("%s\\\\%s\\\\03\\\\%s", path, sdf_4.format(cal.getTime()), startDate));
|
|
|
|
|
|
|
|
|
|
//cal.add(Calendar.MONTH, 1); //1달 더해줌
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cal.add(Calendar.DATE, 1); //1일 더해줌
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e ) {
|
|
|
|
|
@ -76,53 +71,52 @@ public class FileMove {
|
|
|
|
|
if (fileNames[i].exists()) {
|
|
|
|
|
if (original_dir.exists()) {
|
|
|
|
|
}
|
|
|
|
|
File MoveFile = new File(move_dir, fileNames[i].getName());
|
|
|
|
|
File MoveFile = new File(move_dir, fileNames[i].getName());
|
|
|
|
|
fileNames[i].renameTo(MoveFile); // 변경(이동)
|
|
|
|
|
System.out.println(fileNames[i].getName()); // 폴더내에 있는 파일 리스트
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} // end for
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(pathOrg); // 폴더내에 있는 파일 리스트
|
|
|
|
|
System.out.println(path); // 폴더내에 있는 파일 리스트
|
|
|
|
|
System.out.println(path); // 폴더내에 있는 파일 리스트
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void makeDirSub() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); //년월일 표시
|
|
|
|
|
SimpleDateFormat sdf_4 = new SimpleDateFormat("yyyy");
|
|
|
|
|
//dateFormat = new SimpleDateFormat("yyyyMM"); //년월 표시
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf_4 = new SimpleDateFormat("yyyy");
|
|
|
|
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cal.set ( 2019, 12-1, 31 ); //종료 날짜 셋팅
|
|
|
|
|
String endDate = dateFormat.format(cal.getTime());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cal.set ( 2016, 1-1, 1 ); //시작 날짜 셋팅
|
|
|
|
|
String startDate = dateFormat.format(cal.getTime());
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
String startDate = dateFormat.format(cal.getTime());
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
String path = "E:\\혼잡_센터_이미지 백업\\New"; //폴더 경로
|
|
|
|
|
File Folder = null;
|
|
|
|
|
while(!startDate.equals(endDate)){ //다르다면 실행, 동일 하다면 빠져나감
|
|
|
|
|
while(!startDate.equals(endDate)){ //다르다면 실행, 동일 하다면 빠져나감
|
|
|
|
|
if(i==0) { //최초 실행 출력
|
|
|
|
|
System.out.println(dateFormat.format(cal.getTime()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startDate = dateFormat.format(cal.getTime()); //비교를 위한 값 셋팅
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Folder = new File(String.format("%s\\\\%s\\\\01\\\\%s", path, sdf_4.format(cal.getTime()), startDate));
|
|
|
|
|
if (!Folder.exists()) {
|
|
|
|
|
try{
|
|
|
|
|
Folder.mkdir(); //폴더 생성합니다.
|
|
|
|
|
System.out.println("폴더가 생성되었습니다.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e){
|
|
|
|
|
e.getStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
System.out.println("이미 폴더가 생성되어 있습니다.");
|
|
|
|
|
}
|
|
|
|
|
@ -131,31 +125,31 @@ public class FileMove {
|
|
|
|
|
try{
|
|
|
|
|
Folder.mkdir(); //폴더 생성합니다.
|
|
|
|
|
System.out.println("폴더가 생성되었습니다.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e){
|
|
|
|
|
e.getStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
System.out.println("이미 폴더가 생성되어 있습니다.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//cal.add(Calendar.MONTH, 1); //1달 더해줌
|
|
|
|
|
cal.add(Calendar.DATE, 1); //1일 더해줌
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void makeDir() {
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf_4 = new SimpleDateFormat ("yyyy");
|
|
|
|
|
|
|
|
|
|
Date dtStart = FileMove.getDate(2007, 1, 1, 0, 0, 0);
|
|
|
|
|
Date dtEnd = FileMove.getDate(2015, 12, 31, 23, 59, 59);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long lStartYear = Long.parseLong(sdf_4.format(dtStart));
|
|
|
|
|
long lEndYear = Long.parseLong(sdf_4.format(dtEnd));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File Folder = null;
|
|
|
|
|
for(long index = lStartYear; index <= lEndYear; index++) {
|
|
|
|
|
String path = "E:\\혼잡_센터_이미지 백업\\New"; //폴더 경로
|
|
|
|
|
@ -164,10 +158,10 @@ public class FileMove {
|
|
|
|
|
try{
|
|
|
|
|
Folder.mkdir(); //폴더 생성합니다.
|
|
|
|
|
System.out.println("폴더가 생성되었습니다.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e){
|
|
|
|
|
e.getStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
System.out.println("이미 폴더가 생성되어 있습니다.");
|
|
|
|
|
}
|
|
|
|
|
@ -177,29 +171,29 @@ public class FileMove {
|
|
|
|
|
try{
|
|
|
|
|
Folder.mkdir(); //폴더 생성합니다.
|
|
|
|
|
System.out.println("폴더가 생성되었습니다.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e){
|
|
|
|
|
e.getStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
System.out.println("이미 폴더가 생성되어 있습니다.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Folder = new File(String.format("%s\\\\%d\\\\03", path, index));
|
|
|
|
|
if (!Folder.exists()) {
|
|
|
|
|
try{
|
|
|
|
|
Folder.mkdir(); //폴더 생성합니다.
|
|
|
|
|
System.out.println("폴더가 생성되었습니다.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e){
|
|
|
|
|
e.getStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
System.out.println("이미 폴더가 생성되어 있습니다.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Date getDate(int year, int month, int date, int hour, int minute, int second) {
|
|
|
|
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
|