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

时间:2017-07-24 07:26:50

标签: windows macos split terminal cat

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

split -b 20mb myFile.zip

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

使用cat terminal命令在Mac上恢复文件没有问题: cat xaa xab > myFile.zip

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

先谢谢

Ishai

1 个答案:

答案 0 :(得分:2)

以下批处理脚本将执行您所需的操作。在batchfile.bat x myFile.zip之前使用它,它循环遍历以指定前缀x开头的所有文件,并使用myFile.zip将它们附加到结果文件type

@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