开发者

Batch file to reduce length of file name

开发者 https://www.devze.com 2023-01-15 18:45 出处:网络
i download file names like this.. batchengine-6099-1283555555-60054_20100910_0006.era and want to rename them to 600开发者_如何学JAVA54_20100910_0006.era. The names change but format same, need for st

i download file names like this.. batchengine-6099-1283555555-60054_20100910_0006.era and want to rename them to 600开发者_如何学JAVA54_20100910_0006.era. The names change but format same, need for statement to rename of all big files ending in .era


I don't have access to a Windows box, but something like:

SETLOCAL EnableExtensions EnableDelayedExpansion
FOR %%I IN (batchengine-*.era) DO (
    SET NAME=%%~nI
    RENAME "%%I" "!NAME:~28!%%~xI"
)
ENDLOCAL

Type FOR /?, SET /?, and SETLOCAL /? in the console for all of the details on the syntax. Hopefully I have something pretty close. You need to introduce new variables within the loop so that you can access the extended syntax to subscript - e.g., !NAME:~28! selects the substring starting at character 28. The !NAME! is a delayed expansion reference. The need for this is explained in one of the command synopsis pages.

0

精彩评论

暂无评论...
验证码 换一张
取 消