commit
457361dfc9
@ -0,0 +1,8 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,10 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" build-on-make="true" name="createWorkFolder">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/createWorkFolder</output-path>
|
||||
<root id="archive" name="createWorkFolder.jar">
|
||||
<element id="directory" name="META-INF">
|
||||
<element id="file-copy" path="$PROJECT_DIR$/META-INF/MANIFEST.MF" />
|
||||
</element>
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
@ -0,0 +1,5 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
</profile>
|
||||
</component>
|
@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="create_workfolder">
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/create_workfolder.iml" filepath="$PROJECT_DIR$/create_workfolder.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,73 @@
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* @author lwy
|
||||
*/
|
||||
public class CreateWorkFolder {
|
||||
public static void main(String[] args) {
|
||||
// 获取今天的日期,并将其格式化为 "yyyy-MM-dd" 的字符串
|
||||
LocalDate today = LocalDate.now();
|
||||
String dateStr = today.format(DateTimeFormatter.ofPattern("M-d"));
|
||||
|
||||
// 创建今天日期的目录
|
||||
Path dirPath = Paths.get("X:\\" + dateStr);
|
||||
createFolder(dirPath);
|
||||
|
||||
// 在目录下创建三个子目录
|
||||
String[] dirs = {"pic", "pic - 副本", "video", "修改后"};
|
||||
for (String subdir : dirs) {
|
||||
Path subdirPath = Paths.get(dirPath.toString(), subdir);
|
||||
createFolder(subdirPath);
|
||||
}
|
||||
|
||||
// 在目录下创建一个以今天日期命名的txt文件
|
||||
Path filePath = Paths.get(dirPath.toString(), dateStr + ".txt");
|
||||
if (Files.exists(filePath)) {
|
||||
System.out.println("File already exists1: " + filePath);
|
||||
} else {
|
||||
try {
|
||||
Files.createFile(filePath);
|
||||
System.out.println("File created: " + filePath);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Failed to create file: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 在video目录下创建一个转换视频文件
|
||||
Path sourcePath = Paths.get("fastConvertMPG2mp4.bat");
|
||||
Path videoConvertFile = Paths.get(dirPath.toString()+"\\video").resolve("fastConvertMPG2mp4.bat");
|
||||
|
||||
if (Files.exists(videoConvertFile)) {
|
||||
System.out.println("File already exists2: " + videoConvertFile);
|
||||
} else {
|
||||
try {
|
||||
Files.copy(sourcePath, videoConvertFile);
|
||||
System.out.println("File created: " + videoConvertFile);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Failed to create file: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("文件夹和文件创建结束!!!");
|
||||
}
|
||||
|
||||
static void createFolder(Path subdirPath) {
|
||||
if (Files.exists(subdirPath)) {
|
||||
System.out.println("Directory already exists: " + subdirPath);
|
||||
} else {
|
||||
try {
|
||||
Files.createDirectory(subdirPath);
|
||||
System.out.println("Directory created: " + subdirPath);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Failed to create directory: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: CreateWorkFolder
|
||||
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="GENERAL_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="create_workfolder" level="project" />
|
||||
</component>
|
||||
</module>
|
Loading…
Reference in new issue