I have directory which contain no. of file like this
我有没有的目录。像这样的文件
abac_273#jj.txt ,
hhh.78448#kkpp.txt ,
dgfhf@ytyt#llltyui.txt
I need to write batch script where I need to rename those file like this
我需要编写批处理脚本,我需要重命名这些文件
jj.txt , kkpp.txt, llltyui.txt
In simple words, I need to find out # from end and return string after # as output.
简单来说,我需要从#中找出#并在#之后返回字符串作为输出。
Can you please help me out to solve this
能帮我解决这个问题吗?
1 个解决方案
#1
1
for /f "tokens=1*delims=#" %%a in ('dir /b /a-d "*#*"') do echo(ren "%%a#%%b" "%%b"
should provide what you want - reduce each %%
to %
if you execute this from the prompt instead of as a batch line.
应提供您想要的 - 如果您从提示符而不是批处理行执行此操作,请将每个%%减少到%。
If it works correctly for you, change the echo(ren
to ren
to actually do the change - this code will simply report the proposed change to the screen.
如果它对您正常工作,请更改回声(ren to ren实际进行更改 - 此代码将简单地将建议的更改报告给屏幕。
#1
1
for /f "tokens=1*delims=#" %%a in ('dir /b /a-d "*#*"') do echo(ren "%%a#%%b" "%%b"
should provide what you want - reduce each %%
to %
if you execute this from the prompt instead of as a batch line.
应提供您想要的 - 如果您从提示符而不是批处理行执行此操作,请将每个%%减少到%。
If it works correctly for you, change the echo(ren
to ren
to actually do the change - this code will simply report the proposed change to the screen.
如果它对您正常工作,请更改回声(ren to ren实际进行更改 - 此代码将简单地将建议的更改报告给屏幕。