Windows批处理按长度64分割长字符串 [英] Windows batch split long string by length 64

查看:81
本文介绍了Windows批处理按长度64分割长字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图解决这个问题,但没有任何运气.有人可以帮忙吗?

I have tried to figure this out without any luck. Can anyone help on this?

我有一个文件:input.txt 该文件包含一个长字符串-我想将长字符串分成64个长字符串块,然后将内容保存到另一个文件中.

I have a file: input.txt This file contains a long string - and i want to split the long string into 64 long string chunks, and save the content to a different file.

到目前为止,我还没有太多,我知道我必须使用for循环:

I don't have much so far, i know i have to use the for loop:

echo off
set /p base64=<input.txt

for /f "%base64:~0,64%" %%G IN %base64% DO echo %%G

但是如何在行中和批处理脚本中使每个64个字符循环?

But how to make the loop for each 64 characters in line - and in a batch script?

任何帮助将不胜感激.

推荐答案

@ECHO OFF
SETLOCAL
(
FOR /f "delims=" %%i IN (input.txt) DO SET longline=%%i&call:breakit
)>output.txt
GOTO :eof

:breakit
ECHO %longline:~0,64%
SET longline=%longline:~64%
IF DEFINED longline GOTO breakit
GOTO :EOF 

这应该做您想要的-但它可能取决于文件的内容,因为批处理对某些字符敏感.

This should do what you want - but it may depend on the content of the file as batch has sensitivities to certain characters.

这篇关于Windows批处理按长度64分割长字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆