|
iuiu
初级用户
 
积分 32
发帖 15
注册 2007-8-2
状态 离线
|
『楼 主』:
[求助]批量按歌手名建立目录把歌曲移动到目录中
使用 LLM 解释/回答一下
现在有几千首歌,文件名是这样的
王力宏 - Forever Love.mp3
王力宏 - I'm Lovin'it.mp3
万芳 - 不换.mp3
现在想根据文件名中的歌手名分别建立文件夹,并把歌曲移到相对应的歌手的目录中去。该怎么来书写此批处理?请高手不吝执教。非常感谢。
Now there are thousands of songs, and the file names are like this:
Wang Leehom - Forever Love.mp3
Wang Leehom - I'm Lovin'it.mp3
Wan Fang - Bu Huan.mp3
Now I want to create folders respectively according to the singer names in the file names, and move the songs to the corresponding singer's directory. How to write this batch processing? Please expert teach without stint. Thanks a lot.
|
|
2008-8-20 13:43 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
@echo off & setlocal EnableDelayedExpansion
set "Total=0"
for /f "delims=- tokens=1,* " %%i in (' dir /b *.mp3') do (
set /a "Total+=1"
echo 正在处理第!Total!首歌:
if not exist "%%i" md "%%i"
if exist "%%i-%%j" copy "%%i-%%j" "%cd%\%%i"
if exist "%cd%\%%i\%%i-%%j" del "%%i-%%j"
)
echo 处理完毕,共处理首歌~!&pause>nul
严谨的书写方式应该如上。。。。
Last edited by flyinspace on 2008-8-20 at 02:40 PM ]
@echo off & setlocal EnableDelayedExpansion
set "Total=0"
for /f "delims=- tokens=1,* " %%i in (' dir /b *.mp3') do (
set /a "Total+=1"
echo 正在处理第!Total!首歌:
if not exist "%%i" md "%%i"
if exist "%%i-%%j" copy "%%i-%%j" "%cd%\%%i"
if exist "%cd%\%%i\%%i-%%j" del "%%i-%%j"
)
echo 处理完毕,共处理首歌~!&pause>nul
Last edited by flyinspace on 2008-8-20 at 02:40 PM ]
|

知,不觉多。不知,乃求知 |
|
2008-8-20 13:56 |
|
|
huahua0919
银牌会员
    
积分 1608
发帖 780
注册 2007-10-7
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
for /f "tokens=1* delims=-" %%i in ('dir/b/a-d *.mp3') do (
md %%i 2>nul© "%%i-%%j" %%i
)
有必要可以把copy改成move
Last edited by huahua0919 on 2008-8-20 at 02:01 PM ]
```
for /f "tokens=1* delims=-" %%i in ('dir/b/a-d *.mp3') do (
md %%i 2>nul© "%%i-%%j" %%i
)
```
It is necessary to change copy to move if needed.
Last edited by huahua0919 on 2008-8-20 at 02:01 PM ]
|
|
2008-8-20 14:00 |
|
|
iuiu
初级用户
 
积分 32
发帖 15
注册 2007-8-2
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
Originally posted by flyinspace at 2008-8-20 01:56 PM:
@echo off & setloacl EnableDelayedExpansion
set "Total=0"
for /f "delims=- tokens=1,* " %%i in (' dir /b *.mp3') do (
set /a "Total+=1"
echo 正在处 ...
老大,目录是有了,歌都没了,欲哭无泪。
Originally posted by flyinspace at 2008-8-20 01:56 PM:
@echo off & setloacl EnableDelayedExpansion
set "Total=0"
for /f "delims=- tokens=1,* " %%i in (' dir /b *.mp3') do (
set /a "Total+=1"
echo 正在处 ...
Boss, the directory is there, but all the songs are gone, feeling like crying without tears.
|
|
2008-8-20 14:05 |
|
|
huahua0919
银牌会员
    
积分 1608
发帖 780
注册 2007-10-7
状态 离线
|
|
2008-8-20 14:07 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
'dir/b/a-d *.mp3'
1。 不明白,既然已经是按。mp3排列了。还要 /a-d做什么?
难道还要排除 *.mp3 的文件夹?
2。 与其大量的md操作还不如验证一下。
3, 按你的代码应该使用 move指令而不是copy。因为你没有del的操作。。
'dir/b/a-d *.mp3'
1. I don't understand. Since it's already sorted by.mp3, what's the use of /a-d?
Does it still need to exclude the folders with *.mp3?
2. Instead of a large number of md operations, it's better to verify.
3. According to your code, the move instruction should be used instead of copy. Because you don't have the del operation.
|

知,不觉多。不知,乃求知 |
|
2008-8-20 14:09 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
别哭,现在你什么操作都不要做。。
我给你东西。。刚才的代码写错点?不过歌应该被copy到目录下了呀?
Don't cry. Now you don't do anything.
I'll give you something.. The code was written wrong just now? But the song should have been copied to the directory, right?
|

知,不觉多。不知,乃求知 |
|
2008-8-20 14:11 |
|
|
huahua0919
银牌会员
    
积分 1608
发帖 780
注册 2007-10-7
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
我保险求保险,不在我这边运行,什么都难说。所以说你写的代码虽然你可能执行成功但他却出了问题
1.用.mp3做文件夹更定不会错
2用2 >nul的效率比 if exist的效率高
3就是我上面说的
I'm seeking insurance, not running on my side, it's hard to say anything. So the code you wrote may execute successfully but has problems.
1. Using.mp3 as a folder must be correct.
2. The efficiency of 2 >nul is higher than that of if exist.
3. Just what I said above.
|
|
2008-8-20 14:11 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
if exist "%cd%\%%i" del "%%i-%%j"
应该是: if exist "%cd%\%%i\%%i-%%j" del "%%i-%%j"
你的qq是多少?msn也行?
if exist "%cd%\%%i" del "%%i-%%j"
It should be: if exist "%cd%\%%i\%%i-%%j" del "%%i-%%j"
What is your QQ number? MSN is also okay?
|

知,不觉多。不知,乃求知 |
|
2008-8-20 14:13 |
|
|
iuiu
初级用户
 
积分 32
发帖 15
注册 2007-8-2
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
目录都建好了,但是文件都没了,文件夹都是空的。
The directory is all set up, but all the files are gone, and the folders are all empty.
|
|
2008-8-20 14:14 |
|
|
iuiu
初级用户
 
积分 32
发帖 15
注册 2007-8-2
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
Originally posted by huahua0919 at 2008-8-20 02:00 PM:
for /f "tokens=1* delims=-" %%i in ('dir/b/a-d *.mp3') do (
md %%i 2>nul© "%%i-%%j" %%i
)
有必要可以把copy改成move
Last edited by hu ...
这位老大的我也试过了,现在问题是目录是建好了,但多了很多额外的空目录。
原来302个文件1.6g左右,copy过去以后只有902m。
不过还是要谢谢2位。
Originally posted by huahua0919 at 2008-8-20 02:00 PM:
for /f "tokens=1* delims=-" %%i in ('dir/b/a-d *.mp3') do (
md %%i 2>nul© "%%i-%%j" %%i
)
You can change copy to move if necessary
Last edited by hu ...
I tried this boss's code too. Now the problem is that the directories are built, but there are many extra empty directories.
Originally there were 302 files about 1.6g, but after copying, there are only 902m.
But still thank you two.
|
|
2008-8-20 14:18 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
哎。不好意思。
已复制 1 个文件。
有无这个提示??
看来以后代码全加上 if errorlevel
Hey. Sorry about that.
1 file(s) copied.
Is there such a prompt??
It seems that I should add if errorlevel to all code in the future
|

知,不觉多。不知,乃求知 |
|
2008-8-20 14:19 |
|
|
iuiu
初级用户
 
积分 32
发帖 15
注册 2007-8-2
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
正在处理第!Total!首歌:
已复制 0 个文件。
处理完毕,共处理首歌~!
Last edited by iuiu on 2008-8-20 at 02:25 PM ]
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing song number !Total!:
0 files copied.
Processing completed, total of songs processed~!
Last edited by iuiu on 2008-8-20 at 02:25 PM ]
|
|
2008-8-20 14:20 |
|
|
huahua0919
银牌会员
    
积分 1608
发帖 780
注册 2007-10-7
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
那就是你的文件名结构有问题不能够有特殊字符,不然就成空了,所以我就用copy的原因了
That is, there is a problem with your file name structure. It cannot have special characters, otherwise it will be empty. So that's why I used copy.
|
|
2008-8-20 14:21 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
既然有提示?怎么会文件夹里全是空的呢?
Since there are prompts? Why are all the folders empty?
|

知,不觉多。不知,乃求知 |
|
2008-8-20 14:21 |
|