繁体   English   中英

如何在 mac 中拆分文件,然后将其连接到 Windows(例如:使用 split 和 cat)?

[英]How can I split file in mac and then concat it Windows (e.g: using split and cat)?

我尝试使用以下命令拆分文件 Mac:

split -b 20mb myFile.zip

然后我得到一些以 x 开头的文件:

xaa xab

使用cat终端命令在 Mac 上恢复文件没有问题:

cat xaa xab > myFile.zip

但它无法在 Windows 上执行cat命令。 任何可行的解决方案?

以下批处理脚本将满足您的需要。 通过batchfile.bat x myFile.zip使用它,它遍历所有以指定前缀x开头的文件,并使用type将它们附加到结果文件myFile.zip

@echo off

set INVARGS=0
if [%1] == [] set INVARGS=1
if [%2] == [] set INVARGS=1
if %INVARGS% == 1 (
   echo Usage: %0 ^<file_prefix^> ^<result_file^>
   goto eof
)

set "prefix=%~1"
set "resFile=%~2"

rem create new empty file in directory of batch file: %~dp0
break>"%resFile%"
rem loop through all output line of the dir command, unset delimns
rem so that space will not separate
for /F "delims=" %%a in ('dir "%prefix%*" /b /s /a-d') do (
   rem don't use the result file
   if not [%%a] == [%resFile%] (
      rem append the output to file
      type "%%a">>"%resFile%"
   )
)

:eof

上面的批处理文件示例创建了一个损坏的文件。

这可以快速运行并创建一个可用的 zip 文件。

copy /b x* MacOS.zip

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM