Often, when transferring files from the camera folder to a workspace where we would like to analyze the pictures, it becomes difficult to deal with long file and type them out again and again when testing them through a code. Also, the number of files might be too large to manually rename each one of them. Hence, it becomes a necessity to automate the renaming process.
Input : Read 50 files from the folder "C:\Users\Anannya Uberoi\Desktop\myfolder": Snapshot 1 (12-05-2017 11-57).png Snapshot 2 (12-05-2017 11-57).png Snapshot 3 (12-05-2017 11-57).png Snapshot 4 (12-05-2017 11-57).png and so on. Output :Renamed to 1.png 2.png 3.png 4.png and so on.
The files get renamed successfully.
Note: A double slash (\\) is required since one of the backslash (\) acts as an escape character and the other backslash (\) denotes directory change.
This article is contributed by Anannya Uberoi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Jar files in Java
- Working with JAR and Manifest files In Java
- Compressing and Decompressing files in Java
- Files isReadable() method in Java with Examples
- Files size() method in Java with Examples
- Java program to merge two files into a third file
- Files getFileStore() method in Java with Examples
- Files isHidden() method in Java with Examples
- Files delete() method in Java with Examples
- Files deleteIfExists() method in Java with Examples
- Files isExecutable() method in Java with Examples
- Files isWritable() method in Java with Examples
- Java program to merge contents of all the files in a directory
- Java program to merge two files alternatively into third file
- Compressing and Decompressing files using GZIP Format in java