@echo off
setlocal enabledelayedexpansion
for %%h in (*.pdf) do (
set str=%%h
set str=!str: =-!
ren "%%h" "!str!")
[ Last edited by huzixuan on 2007-4-1 at 08:54 AM ]作者: tommy725 时间: 2007-4-1 17:43 谢谢大家,我可不可以这样测试啊,edit file.cmd,然后把代码写进去保存,然后在所在文件夹下运行这个文件.所在文件夹下有三个测试的.pdf文档.但是这个结果怎么出现这个啊:
a duplicate file name exists,or the file can not be found
a duplicate file name exists,or the file can not be found
a duplicate file name exists,or the file can not be found作者: bjsh 时间: 2007-4-1 22:49 直接运行我写的那个;也出现这种错误吗???作者: wuwuwuming 时间: 2007-4-1 23:05 好是好,可是看不懂,真是郁闷~~~~作者: tommy725 时间: 2007-4-2 19:54 我运行了
@echo off
for /f "delims= " %%a in ('dir /b/a *.pdf') do
set "old_name=%%a" &call :re_name
goto exit
:re_name
set "new_name=%old_name:=-%"
ren "%old_name%" "%new_name%"
:exit
运行后说命令的语法不正确
the syntax of the command is incorrect.作者: qingfushuan 时间: 2007-4-2 21:56 标题: 试试这个
我刚才写的,经测试可以更名的
@echo off&setlocal enabledelayedexpansion
for /f "delims=." %%a in ('dir /a-d /b *.pdf') do (
set str=%%a
set str=!str: =-!
ren "%%a".pdf !str!.pdf
)
pause
[ Last edited by tommy725 on 2007-4-2 at 09:52 AM ]作者: acme 时间: 2007-4-13 09:06 好象没有指定路径,可以指定路径吗?
要不怎么知道回更名那些路径下的?作者: fanglor 时间: 2007-4-13 14:07 set str=!str: =-!
能不能说一下这句是什么意思 啊?
谢谢了!作者: bjsh 时间: 2007-4-13 21:25 set str=%str: =-%