|
tianzizhi
高级用户
   
积分 623
发帖 214
注册 2006-9-22
状态 离线
|
『楼 主』:
求一cmd下分割+合并文件的dos程序!
[已使用 LLM 解释]
dos编程高手们,我想有一个cmd下分割文件的dos程序,把它作为系统文件放到system32里,功能如下:
1,指定大小分割文件(基本功能)
2,合并分割后的文件(用这个程序合并和copy命令合并都可以)
3,音频和视频之类的文件分割后文件可以正常播放.
4,自定义分割文件存放目录.
精通编程的朋友编一个这样的程序难度不会大吧,帮我一下这个忙吧,谢谢!!!
Experts in DOS programming, I want a DOS program that splits files under cmd. Put it as a system file in system32. The functions are as follows:
1. Split files with specified size (basic function)
2. Merge split files (this program can be used to merge and also can be merged with the copy command)
3. Audio and video and other files can be played normally after splitting.
4. Customize the storage directory of split files.
Friends who are proficient in programming, it shouldn't be difficult to compile such a program. Help me with this favor, thank you!!!
LLM 解释
需求可行性与技术实现说明
你提出的需求在 DOS/Windows 命令行环境下完全可实现,且核心功能可通过原生工具或简单批处理/程序满足,以下是具体分析:
1. 核心功能的技术实现方案
(1)指定大小分割文件
-
DOS 原生工具:若使用 FreeDOS,其自带
split 命令(类似 Unix),支持按字节/KB/MB 分割(如 split -b 10M largefile.iso part_);MS-DOS 无原生 split,但可通过第三方工具(如 GNU Utils for DOS 中的 split.exe)实现,这类工具可放入 system32(Windows DOS 模拟环境)或 DOS 系统目录。
-
C 语言实现逻辑:通过
fopen 打开源文件,循环读取指定字节数(如 1024*1024 字节=1MB),写入以序号命名的分割文件(如 file.001、file.002),需注意二进制模式打开(fopen("file", "rb"))以保证音频/视频等二进制文件不损坏。
(2)合并文件
-
原生命令:DOS/Windows 下
copy /b 命令支持二进制合并,无需额外程序(如 copy /b part_aa + part_ab + part_ac mergedfile.iso);若分割时使用序号命名(如 file.001),可简化为 copy /b file.* mergedfile(依赖文件名按序号排序)。
-
程序实现:按分割序号顺序打开所有子文件,依次读取并写入目标文件即可。
(3)音频/视频文件分割后可播放
需满足分割时不破坏文件结构:
- 必须以二进制模式读写文件(避免文本模式下的换行符转换,如 DOS 的
\r\n 与 Unix 的 \n 混淆);
- 分割点无需对齐文件格式的“块”(如 MP3 的帧、AVI 的块)—— 多媒体播放器通常具备流解析容错能力,即使中间分割,也能从有效帧开始播放(仅开头/结尾可能有极短的无效片段)。
(4)自定义分割文件存放目录
- 批处理/程序中可通过参数传递实现:例如程序接受
-o D:\split_files 作为输出目录参数,在代码中通过 mkdir(DOS)或 CreateDirectory(Windows API)创建目录,再将分割文件写入该路径。
2. 程序实现的技术难度
-
C 语言实现:核心逻辑仅需约 100-200 行代码,涉及文件 I/O、命令行参数解析(如
argc/argv)、目录操作,对熟悉 DOS 编程的开发者而言属于基础功能,无技术难点。
-
注意事项:需处理边界情况(如源文件大小不是分割大小的整数倍时,最后一个文件更小)、文件名长度限制(DOS 8.3 格式需控制序号位数,如
file.001 而非 file.1234)、权限问题(输出目录是否可写)。
3. 历史语境补充
你提到“放到 system32 里”,推测实际使用环境是Windows XP/7 的命令提示符(cmd.exe)(而非纯 DOS):
- Windows 的
cmd.exe 兼容 DOS 命令,且 system32 中的程序可直接调用;
- 若需纯 DOS 环境(如 MS-DOS 6.22),则程序需编译为 16 位 DOS 可执行文件(使用 Turbo C、Watcom C 等编译器),放入
C:\DOS 目录即可。
4. 替代方案:利用现有工具
若不想自行编译程序,可直接使用GNU Coreutils for DOS(如 split.exe、cat.exe),这些工具是开源且合法的,支持你需要的所有功能,且可直接放入系统目录使用。
综上,你需求的功能实现难度低,核心逻辑清晰,且有成熟的工具/代码参考。若需要具体的 C 代码框架或批处理示例,可进一步补充说明。
|
|
2006-12-20 06:01 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
恩,lxmxn正在开发这个东东,可能马上就出来了~~
Well, lxmxn is developing this thing, and it might come out soon~~
|
|
2006-12-20 07:58 |
|
|
tigerpower
中级用户
   大师兄
积分 377
发帖 99
注册 2005-8-26
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
使用 split :
C:>split -a1 -b3m Jay-HairLikeSnow.mp3 发如雪
Using split:
C:>split -a1 -b3m Jay-HairLikeSnow.mp3 发如雪
附件
1: split.zip (2006-12-20 09:17, 8.09 KiB, 下载附件所需积分 1 点
,下载次数: 143)
|
|
2006-12-20 09:17 |
|
|
tianzizhi
高级用户
   
积分 623
发帖 214
注册 2006-9-22
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
强人,谢谢....这个是自己写的吗,网上找不到的,能否用c语言写出这样类似的程序,我想要一下这个代码,请大家帮忙........
Great guy, thanks.... Is this written by yourself? I can't find it online. Can you write a similar program in C language? I want this code, please help...
|
|
2006-12-20 09:25 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
split这个东西很早了哦,我记得现在用的都还是几年前出的,不过确实很好用,合并可以copy /b
The split is something that's been around for a long time. I remember that what we're using now is still the one released a few years ago, but it's really useful. For merging, you can use copy /b
|
|
2006-12-21 09:50 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
lxmxn那个是利用 WinRAR 版本的
::code by lxmxn @ cn-dos.net
::Divide file into pieces.
@echo off&setlocal EnableDelayedExpansion
if not "%~s1"=="" (
echo %~s1
set "file=%~s1"
goto last
) else (goto begin)
:begin
cls
set /p file=请输入你要分割的文件名:
:last
for /f "delims=" %%i in ("%file%") do (
echo %%i
set filename=%%~nxi
set filesize=%%~zi
set name=%%~ni
set yslj=%%~dpi
set /a kbsize=%%~zi/1024
echo !yslj!
)
:redo
set /p fen= %filename% 文件的大小是 %filesize% 字节(大约 %kbsize% KB),请输入你要分隔出的文件大小:
if %fen% gtr %filesize% (
cls
echo 输入的错误,请重新输入~
goto :redo
)
set /a over=%filesize%/%fen%
set /a over_=%over%+1
set /p choose=大概可以从 %filename% 中分割出 %over_% 个文件,是否继续?【Y】/【N】
echo.&echo.
if /i not "%choose%"=="y" goto :end
if exist new_%name%\*.rar del new_%name%\*.rar /a /q
md new_%name% 2>nul
if %over_% geq 1 if %over_% leq 9 set num=1
if %over_% geq 10 if %over_% leq 99 set num=01
if %over_% geq 100 if %over_% leq 999 set num=001
if %over_% geq 1000 if %over_% leq 9999 set num=0001
rar a /v%fen%b /df /m0 /inul new_%name%\new_%name%.rar %file%
set /p choose1=是否要将分割的文件合并?【Y】/【N】
echo.&echo.
if /i not "%choose1%"=="y" goto :end
rar x /kb /df /inul new_%name%\new_%name%.part%num%.rar "%yslj%"
pause&endlocal
goto :eof
:end
set /p _=操作被取消……
start.
goto :eof
lxmxn is using a version of WinRAR
::code by lxmxn @ cn-dos.net
::Divide file into pieces.
@echo off&setlocal EnableDelayedExpansion
if not "%~s1"=="" (
echo %~s1
set "file=%~s1"
goto last
) else (goto begin)
:begin
cls
set /p file=Please enter the file name you want to split:
:last
for /f "delims=" %%i in ("%file%") do (
echo %%i
set filename=%%~nxi
set filesize=%%~zi
set name=%%~ni
set yslj=%%~dpi
set /a kbsize=%%~zi/1024
echo !yslj!
)
:redo
set /p fen= The size of the %filename% file is %filesize% bytes (approximately %kbsize% KB), please enter the size of the file you want to separate:
if %fen% gtr %filesize% (
cls
echo Incorrect input, please re-enter~
goto :redo
)
set /a over=%filesize%/%fen%
set /a over_=%over%+1
set /p choose=Approximately, %over_% files can be split from %filename%, continue? /
echo.&echo.
if /i not "%choose%"=="y" goto :end
if exist new_%name%\*.rar del new_%name%\*.rar /a /q
md new_%name% 2>nul
if %over_% geq 1 if %over_% leq 9 set num=1
if %over_% geq 10 if %over_% leq 99 set num=01
if %over_% geq 100 if %over_% leq 999 set num=001
if %over_% geq 1000 if %over_% leq 9999 set num=0001
rar a /v%fen%b /df /m0 /inul new_%name%\new_%name%.rar %file%
set /p choose1=Do you want to merge the split files? /
echo.&echo.
if /i not "%choose1%"=="y" goto :end
rar x /kb /df /inul new_%name%\new_%name%.part%num%.rar "%yslj%"
pause&endlocal
goto :eof
:end
set /p _=Operation canceled……
start.
goto :eof
|
|
2006-12-21 23:52 |
|
|
poor
初级用户
 
积分 160
发帖 36
注册 2006-12-23
状态 离线
|
|
2006-12-23 13:22 |
|
|
陈沫
中级用户
  
积分 250
发帖 54
注册 2003-6-8
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
我以前用 BC3.0 写的一个,但原码?
主要是用来‘在字符界面显示中文’,
作编程练习写的,
待我重新编译了再放上来。:P
Last edited by 陈沫 on 2008-2-17 at 01:33 AM ]
I used to write one with BC3.0, but the source code? Mainly used to 'display Chinese in the character interface', written for programming practice, wait for me to recompile it and put it up later. :P
Last edited by 陈沫 on 2008-2-17 at 01:33 AM ]
|

http://lingding.vicp.net
或许能帮你忙 |
|
2007-1-10 10:34 |
|
|
yz1test
新手上路

积分 2
发帖 1
注册 2007-3-30
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
正需要,不知是不是管用,谢谢楼主
Just what I needed, not sure if it will work, thanks the LZ
|
|
2007-3-30 04:57 |
|
|
oilio
高级用户
    前进者
积分 641
发帖 303
注册 2007-1-10
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
split有没有中文的参数解释啊,有点不太明白英文。
Does split have Chinese parameter explanations? I don't quite understand the English.
|

我相信总有一天,总会遇到一个人可以相濡以沫、相吻以湿! |
|
2007-5-11 17:29 |
|
|
zhzhh521
新手上路

积分 2
发帖 1
注册 2007-11-12
状态 离线
|
|
2007-11-13 15:37 |
|
|
332567878
新手上路

积分 10
发帖 5
注册 2007-11-25
状态 离线
|
『第 12 楼』:
我想要split
使用 LLM 解释/回答一下
我想要,但是我没有积分
I want to, but I don't have points
|
|
2007-11-25 00:21 |
|
|
332567878
新手上路

积分 10
发帖 5
注册 2007-11-25
状态 离线
|
『第 13 楼』:
electronixtal
使用 LLM 解释/回答一下
怎么我用的时候只出来一个空文件夹啊?
Why do I only get an empty folder when I use it?
|
|
2007-11-26 14:28 |
|
|
332567878
新手上路

积分 10
发帖 5
注册 2007-11-25
状态 离线
|
『第 14 楼』:
借地方用用
使用 LLM 解释/回答一下
分割合并
@echo off
copy rar.exe split.exe c:\windows\
set /p file=请输入要分割的文件名
rar a -m0 %file%
ping 127.0.0.1 -n 4>nul
split %file%.rar --b10000000 --part'.
ping 127.0.0.1 -n 4>nul
if existpart'.aa copy /b 01.jpg+part'.aa part01.jpg
md \01\ \02\ \03\
move part??.jpg \01\ %file% \02\ %file%.rar \03\
Split and Merge
@echo off
copy rar.exe split.exe c:\windows\
set /p file=Please enter the file name to split
rar a -m0 %file%
ping 127.0.0.1 -n 4>nul
split %file%.rar --b10000000 --part'.
ping 127.0.0.1 -n 4>nul
if exist part'.aa copy /b 01.jpg+part'.aa part01.jpg
md \01\ \02\ \03\
move part??.jpg \01\ %file% \02\ %file%.rar \03\
|
|
2007-11-28 09:13 |
|
|
110cjy
新手上路

积分 4
发帖 2
注册 2007-12-2
状态 离线
|
|
2007-12-12 03:28 |
|