Rename files based on folder name
I'm looking for the proper command or script that will rename many files sequentially but prefix them with the name of the folder. For example, I have photos organized in folders by date. The folder for 2006 has folders for Jan, Feb, March and so on. In these folders the pics are just named 001.jpg, 002.jpg and so on. I'd like move all the pics in the sub folders to the main 2006 folder but obviously there are a lot with the same name. I'd like to rename the pics in the Jan to be Jan_001.jpg and so on. I know I can do this folder by folder specifying the pattern but I'll have to go through a lot of folders for each year of pics.
I'd like a command that will go through the 2006 folder recursively and rename all the pics in the sub folders based on the name of the folder. Then it should move them all to the parent folder. I hope that makes sense. I know how to use find to rename or move but not how to have it choose patterns based on the name of the folder.
Thanks.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Ubuntu Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Nikoleta Verbeck
- Solved:
- Last query:
- Last reply: