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.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.