I want to rename a folder of this type of name
. I'm new to batch
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
Thanks. I mean I want to programmatically rename it. Cos the version number might change anytime.
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!]
Silly me. Thanks anyway. I have a folder of name in form
and I am writing a cmd script against it. I want to rename it to form
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
for future preference
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.
wow It works. Please Explain or point me to somewhere I can learn about the for loop yntax with the tokens and delim. Thanks
At the command prompt, type: FOR /?
You may also consult the FOR command description in this site: http://ss64.com/nt/for_cmd.html
or search the web for the vast amount of related questions and answers...