纠正答案:求提取txt文件第一行作为文件名的批处理命令bat
纠正答案:求提取txt文件第一行作为文件名的批处理命令bat 上次给的答案不太直接,Shortway 大师给的方法很不错。 Shortway 大师,您能否再加段代码,文件名太长了, 30个字节以内最好 积分不足,改天一定奉送60分
'bat对文件的读写、判断等操作极弱,所以推荐VBS。 '使用也很简单:记事本输入→保存到目标文件夹,命名为“RenameText。vbs”文件→双击运行。 ----代码开始----- Option Explicit On Error Resume Next ' 容错语句,避免程序崩溃 '有可能重命名文件已经存在,忽略错误。
Dim fso,fs,f Dim i Dim strNewName Const strCurrentPath = "。" '当前目录 Msgbox "根据文本文件第一行批量重命名的VBS程序" & vbcrlf & vbcrlf & "Created By Shortway",0," " Set fso = Wscript。
CreateObject("Scripting。FileSystemObject") Set fs = fso。GetFolder(strCurrentPath)。Files i = 0 For Each f In fs '遍历当前文件夹内每个文件 If LCase(right( ,3))="txt" Then '判断是否是文本文件 strNewName = Trim(fso。
OpenTextFile(f, 1, False)。ReadLine) '得到第一行 '以下剔除不能作文件名的特殊字符 strNewName = Replace(strNewName, "\", "") strNewName = Replace(strNewName, "/", "") strNewName = Replace(strNewName, ":", "") strNewName = Replace(strNewName, "*", "") strNewName = Replace(strNewName, "?", "") strNewName = Replace(strNewName, """", "") strNewName = Replace(strNewName, ">", "") strNewName = Replace(strNewName, "<", "") strNewName = Replace(strNewName, "|", "") strNewName = left(strNewName,30) '有时第一行文字太多了,就选30个字符了 =strNewName & "。
txt" i = i + 1 End if Next Msgbox i & "个文件改名完成!(忽略重名)" Set fs = Nothing Set fso = Nothing 。
答:for %%i in (*.txt) do call :re_name "%%i" pause exit :re_name for /f "delims=" %...详情>>
答:我建议你去--天下网吧联盟 这里面都是网吧业主和网管交流的论坛,你可以自己注册一个用户进去看看,你可以和他们交流也可以寻求他们的帮助,我想没有你解决不了的问题,...详情>>
答:格式化文本区域的段落标记,用于规定文本和层的属性和位置等。比如: 新浪网 用来规定 新浪网 这三个字居中显示。 文本中心(CENTER)、左(LEFT)或右(R...详情>>