English 中文(简体)
批号更名为文件夹。
原标题:batch rename the files in a folder

我有一些文件(大约10 000份档案)格式简便。

SDEF-2001-23965-236.pdf
SlkF-1991-65-123.pdf

我想通过将4个特性从尾去除来核实档案名称是否以通缉格式重新命名。

SDEF-2001-23965-236.pdf >>SDEF-2001-23965.pdf

SlkF-1991-65-123.pdf    >>SlkF-1991-65.pdf 

我不知道我应如何建立一个能够做我需要的事情的编案。

问题回答

你们需要在监督事务司中“规划”,以下联系是有用的:

rel=“nofollow” http://www.dostips.com/DtTiStringManipulation.php


如果您有*.pdffile with Format aaaa-bbb-cc-ddd.ext (4个部分+延长)

建立名为rn.bat的文件:

@echo off
set str=%1
for /f "tokens=1,2,3,4 delims=- " %%a in ("%str%") do set p1=%%a&set p2=%%b&set p3=%%c&set p4=%%d
set ext=%str:~-4%
set "result=%p1%-%p2%-%p3%%ext%"
ren %1 %result%

建立名为rnall.bat的文件:

@echo off
for %%i in (%1) do rml.bat %%i

然后进入指挥系统:rnall *.pdf in commmand line。

This is not best code, you can use functions to do it better





相关问题
complex batch replacement linux

I m trying to do some batch replacement for/with a fairly complex pattern So far I find the pattern as: find ( -name *.php -o -name *.html ) -exec grep -i -n hello {} + The string I want ...

How to split a string by spaces in a Windows batch file?

Suppose I have a string "AAA BBB CCC DDD EEE FFF". How can I split the string and retrieve the nth substring, in a batch file? The equivalent in C# would be "AAA BBB CCC DDD EEE FFF".Split()[n]

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

热门标签