更新时间:2023-01-31 14:35:49
如果可以访问Windows shell,则可以使用:
If you have access to a Windows shell, you can use:
@echo off
setlocal EnableDelayedExpansion
REM loop over all files in the cwd
for /f %%a in ('dir /a-d /b') do (
REM store this filename in a variable so we can do substringing
set ThisFileName=%%a
REM now take a substring
set ThisShortFileName=!ThisFileName:~0,255!
REM finally, the rename:
echo ren %%a !ThisShortFileName!
)
:EOF
endlocal
(注意:我在重命名命令之前添加了一个回显,因此您可以在实际运行它之前直观地验证它是否可以工作.在我的机器上可以工作.)
(Note: I have added an echo before the rename command just so you can visually verify that it works before actually running it. Works on my box.)
我确定现在在* nix框上的人可以为bash编写类似的脚本,但是我陷入了Windows世界:)
I'm sure somebody who's on a *nix box right now could make a similar script for bash, but I'm stuck in Windows world :)
祝你好运!