You are not logged in.
I want to rename a folder of this type of name
abc-cde-1.2.3_4
to
1.2.3_4
. I'm new to batch
Offline
You must be more precise in the details of your problem. Otherwise, this is a valid solution to your question:
ren abc-cde-1.2.3_4 1.2.3_4
Antonio
Offline
Thanks. I mean I want to programmatically rename it. Cos the version number might change anytime.
Offline
Have you a folder with a name of this form: "xxx-yyy-zzz" and you want to rename it to just "zzz"? That is: is the name comprised of precisely three parts separated by dash and the new name is the last part?
Is there just one folder with this name format? May be more folders? What to do in this case?
[Please: do NOT reply "Yes". Copy this text and rephrase it so you correctly describe your problem. Note that your last reply did NOT explained why "ren abc-cde-1.2.3_4 1.2.3_4" is not a valid solution for your problem: "the version number might change anytime" means nothing for us!]
Antonio
Offline
Silly me. Thanks anyway. I have a folder of name in form
abc-cde-1.2.3_4
and I am writing a cmd script against it. I want to rename it to form
1.2.3_4
only the last part. Or striping it to be wherever the digit begin. I have tried stuff like
ren "abc-cde-*" "*"
but the wildcard rename the folder to the same name. I want the script to be able to work incase someone else have a folder of kind
abc-cde-1.2
for future preference
Offline
for /F "tokens=1-3 delims=-" %%a in ('dir /A:D /B abc-cde-*') do ren "%%a-%%b-%%c" "%%c"
This line rename all folders with a name like "abc-cde-*" into the third dash-separated part of its name.
Offline
wow It works. Please Explain or point me to somewhere I can learn about the for loop yntax with the tokens and delim. Thanks
Offline
At the command prompt, type: FOR /?
You may also consult the FOR command description in this site: https://ss64.com/nt/for_cmd.html
or search the web for the vast amount of related questions and answers...
Offline