I'm trying to come up with a solution for this issue using only windows cmd line if it's possible.
I have a series of files that look like the follo开发者_如何转开发wing,
[sometexthere233] Tv episode 1
[sometexthere233] Tv episode 2
[sometexthere233] Tv episode 3
I would like to detect any file names in the current directory that contain text within brackets as the prefix, and remove that portion of the file name.
Tv episode 1
Tv episode 2
Tv episode 3
I've done some research using the windows REN command, but I can seem to approach the right syntax or wild card for it to execute.
Any help on how to do this, or to create a bat file that is able to do this would be greatly appreciated.
The following script searches the current directory for files matching the mask [*] *
and renames them by removing the bracketed part and the space after it:
@ECHO OFF
FOR %%F IN ("[*] *") DO CALL :process "%%F"
GOTO :EOF
:process
SET oldname=%1
SET "newname=%~nx1"
SET "newname=%newname:*] =%"
RENAME %oldname% "%newname%"
精彩评论