Hey guys,
The question is very simple: How to rename a file to its parent folder name?
The situation is as follows: I have just over 150 folders with each 1 file in it. Now, these single files have random names. So I want to rename them to the name of the folder they are in as they represent articles.
Searching through the posts I have found several posts where people want to rename but not a situation like this. Also the MRT I could not figure out how to do this. Nor in combination with a plugin.
Am I missing the obvious or is it not that simple?
Regards,
RolandD
How to rename a file to its parent folder name?
Moderators: Hacker, petermad, Stefan2, white
How to rename a file to its parent folder name?
Registered user #92105
- majkinetor !
- Power Member
- Posts: 1580
- Joined: 2006-01-18, 07:56 UTC
- Contact:
U can to do it via batch.
In single folder u use:
This will rename the file in one concrete folder to match its parent name.
You then call this script for eatch folder using for /R command
EDIT: but sombra did it much easier. I didn't know about [p]
In single folder u use:
Code: Select all
::get the file name
dir /b > out
set /P F=<out
::get the dir name
for /F "tokens=*" %%I in ("%CD%") do set D=%%~nI
::rename
ren %F% %D%
You then call this script for eatch folder using for /R command
EDIT: but sombra did it much easier. I didn't know about [p]
Habemus majkam!