你好:)當一個朋友給你一個mp3文件,最常見的標題是這樣命名的:「avenged_sevenfold _-_ buried_alive.mp3」。我想創建一個腳本,允許我通過「」(空格)替換「_」來重命名當前庫中的每個文件和文件夾。這是非常長的手動重命名每個文件;我的腳本是在這裏:通過替換子串批量重命名
@echo off
title Merci qui ?
:debut
echo do you want to rename every files/foldes by replacing "_" by " "? (y/n)
set /p choix=
if %choix%==y (
goto renomage)
if %choix%==n (
goto end)
goto debut
:renomage
set /a x=1 :pointeur de fichier
set /a compteurA=0
set /a compteurB=0
for /f %%a in ('dir /b /a:-d *.*') do set /a compteurA+=1
for /f %%a in ('dir /b /a:d *.*') do set /a compteurB+=1
echo %compteurA% fichiers %compteurB% dossiers
set /a n=compteurA+compteurB
echo number of folder/files batch included %n%
:while1
if %x% GTR %n% goto prochain1
set Strin=???name?ofthe?dossier?number?x?????????????
for /f "tokens=1,* delims=[,]" %%A in ('"%comspec% /u /c echo:%Strin%|more|find /n /v """') do `set /a l=%%A-4`
echo Le nom contient %l% lettres.
:leftspace
set Strin=%Strin:_= %
set str=%Strin:~0,1%
if %str% EQU " "(
set Strin=%Strin:~1,%l%-1%
goto leftspace)
SET /A x +=1
goto while1
:prochain1
echo Success ! (or not)
pause
:end
我只需要幫助這條線:
set Strin=???name?ofthe?dossier?number?x?????????????
否則剩下的應該沒問題。如果你有一些批評什麼的,去=)
如果您只是對重新命名mp3文件感興趣(而不是專門爲此編寫程序),則有很多用於管理音樂收藏的程序。看看[Picard](https://musicbrainz.org/doc/MusicBrainz_Picard) –
沒有^^我對一個程序批量感興趣;重命名音樂只是一個編程的藉口:p – Disconected
可能重複的[批處理文件腳本從文件名(Windows)中刪除特殊字符](http://stackoverflow.com/questions/261515/batch-file-script-to-刪除特殊字符從文件名窗口) – bummi