|
thisiscx
新手上路

积分 11
发帖 6
注册 2007-11-9
状态 离线
|
『楼 主』:
排序mp3播放顺序,可处理长文件和含空格的文件名
使用 LLM 解释/回答一下
我编写的用dos批处理排序mp3播放顺序。请指正。
通常播放的顺序即为复制的顺序。因此,控制歌曲文件向U盘或mp3播放器的复制顺序即可产生按指定顺序播放的效果。顺序可以为修改时间、文件大小、文件名、扩展名的正反序。排序方式在dir的参数/O中指定,/O-d为将优先复制修改时间最新的文件。更多的排序方式参见dir /?中/O的内容。
在本示例批处理中默认U盘(或mp3播放器)盘符为J:。在D:有d:\music文件夹,歌曲文件在d:\music中。示例批处理lcopy.bat的内容为:
rem 批处理文件名:lcopy.bat
rem 功能:按指定顺序复制文件,顺序可以为修改时间、文件大小、文件名、扩展名的正反序
rem 排序方式在dir的参数/O中指定,/O-d为将优先复制修改时间最新的文件
rem 典型应用:按指定顺序复制mp3文件到U盘,通常复制的顺序即为播放的顺序
rem 参数:默认U盘盘符为J:。在D:有d:\music文件夹,mp3文件在d:\music中
@echo 按指定顺序复制mp3文件到U盘.............................................................
d:
cd\music
if exist (lcopy.txt) del lcopy.txt
dir /o-d /b >lcopy.txt
FOR /F "delims=;" %%i in (lcopy.txt) do copy /y "%%i" j:\music
del lcopy.txt
@echo 复制结束...............................................................................
I wrote a DOS batch script to sort the playback order of MP3s. Please correct it.
Usually, the playback order is the same as the copying order. Therefore, controlling the copying order of song files to a USB flash drive or MP3 player can produce the effect of playing in the specified order. The order can be the reverse order of modification time, file size, file name, or extension. The sorting method is specified in the /O parameter of dir. /O-d will give priority to copying the files with the latest modification time. For more sorting methods, refer to the content of /O in dir /?.
In this sample batch script, the default drive letter of the USB flash drive (or MP3 player) is J:. There is a d:\music folder on D:, and the song files are in d:\music. The content of the sample batch script lcopy.bat is:
rem Batch file name: lcopy.bat
rem Function: Copy files in the specified order. The order can be the reverse order of modification time, file size, file name, or extension
rem The sorting method is specified in the /O parameter of dir. /O-d will give priority to copying the files with the latest modification time
rem Typical application: Copy MP3 files to the USB flash drive in the specified order. Usually, the copying order is the playback order
rem Parameter: The default drive letter of the USB flash drive is J:. There is a d:\music folder on D:, and the MP3 files are in d:\music
@echo Copy MP3 files to the USB flash drive in the specified order.............................................
d:
cd\music
if exist (lcopy.txt) del lcopy.txt
dir /o-d /b >lcopy.txt
FOR /F "delims=;" %%i in (lcopy.txt) do copy /y "%%i" j:\music
del lcopy.txt
@echo Copy completed...............................................................................
|
|
2007-11-14 12:06 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
这个命令就可以搞定了:
for /f "delims=" %%a in ('dir /o-d/s/b/a-d D:\music') do copy "%%a" J:\music
This command can get it done:
for /f "delims=" %%a in ('dir /o-d/s/b/a-d D:\music') do copy "%%a" J:\music
|
|
2007-11-14 16:14 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
需要修改的地方:
既然用“>lcopy.txt”,那就可以不用“if exist (lcopy.txt) del lcopy.txt”,如果单纯用“dir /o-d /b >lcopy.txt”生成列表,会连新生成的“lcopy.txt”也会加入,改为“dir /o-d /b *.mp3>lcopy.txt”
The places that need to be modified:
Since using ">lcopy.txt", there is no need to use "if exist (lcopy.txt) del lcopy.txt". If you simply use "dir /o-d /b >lcopy.txt" to generate the list, the newly generated "lcopy.txt" will also be included. Change it to "dir /o-d /b *.mp3>lcopy.txt"
|

 |
|
2007-11-15 09:20 |
|
|
thisiscx
新手上路

积分 11
发帖 6
注册 2007-11-9
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
谢谢lxmxn版主和zh159大侠。
Thanks to moderator lxmxn and大侠 zh159.
|
|
2007-11-15 16:26 |
|
|
thisiscx
新手上路

积分 11
发帖 6
注册 2007-11-9
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
请问一下,按lxmxn版主的语句执行时提示找不到文件,因为实际执行时“”中只有文件名,没有路径名,请问应该怎么办?
May I ask, when executing according to the statements of moderator lxmxn, it prompts that the file is not found. Because when actually executing, there is only the file name in the "", without the path name. How should I deal with this?
|
|
2007-11-15 16:43 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
应该不会出现这个问题的,你是写成“D:\music”这个形式的么?
It should not have this problem. Did you write it in the form of "D:\music"?
|
|
2007-11-15 18:06 |
|
|
thisiscx
新手上路

积分 11
发帖 6
注册 2007-11-9
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
Originally posted by lxmxn at 2007-11-15 18:06:
应该不会出现这个问题的,你是写成“D:\music”这个形式的么?
我是将你的语句复制下来,去掉了/s/a-d后直接用的。有问题吗?
Originally posted by lxmxn at 2007-11-15 18:06:
This problem should not occur. Did you write it in the form of "D:\music"?
I copied your statement, removed /s/a-d, and used it directly. Is there a problem?
|
|
2007-11-16 12:20 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
当然有问题了。
你如果去掉的话,就这样吧:
for /f "delims=" %%a in ('dir /o-d/b D:\music') do copy "D:\music\%%a" J:\music
Of course there is a problem.
If you remove it, it will be like this:
for /f "delims=" %%a in ('dir /o-d/b D:\music') do copy "D:\music\%%a" J:\music
|
|
2007-11-16 12:41 |
|
|
thisiscx
新手上路

积分 11
发帖 6
注册 2007-11-9
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
明白了,谢谢lxmxn版主
Got it, thank you, moderator lxmxn
|
|
2007-11-19 10:27 |
|
|
thisiscx
新手上路

积分 11
发帖 6
注册 2007-11-9
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
请问,怎样用copy命令按随机顺序复制文件呢?
Excuse me, how to use the copy command to copy files in random order?
此帖被 -2 点积分 点击查看详情 评分人:【 HAT 】 | 分数: -2 | 时间:2009-2-3 05:38 |
|
|
|
2009-2-2 17:30 |
|
|
523066680
银牌会员
     SuperCleaner
积分 2362
发帖 1133
注册 2008-2-2
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
(我插个嘴)不得不惊讶一下…… 上面是 2007到2009之间的超长对话 ……
(Let me interject) Have to be surprised... The above is a super-long conversation between 2007 and 2009...
|

综合型编程论坛
我的作品索引 |
|
2009-2-2 18:27 |
|