Batch; Text to File; Add n Spaces after var

July 23, 2011 at 09:46:52
Specs: Windows 7

I was wondering whether anyone could suggest a method or program that could be used in conjunction with a batch script which would allow me to write a variable + n spaces to a text file.

E.g. Write "this is a test" with "10" spaces after, so that the result would be "this is a test "

Purpose for such a request is, as you may perceive, a formatting problem. the "10" has to be a variable which can change depedning on the size of the text that needs to be used

Your help would be much appreciated.

Thanks in advance.

See More: Batch; Text to File; Add n Spaces after var

Report •

July 23, 2011 at 16:18:06
Edit: My post deleted and this substituted. I think this script was posted by Judago, if it is the work of another member I aplogise for not remembering.

While this handles a .csv file I'm sure you will be able to modify it for your own purposes.

@echo off
setlocal enabledelayedexpansion

echo a,b,c,de
echo a2,b2,c2,de2
echo 3,b b3,c234567890,de3

for /f "tokens=1-4 delims=," %%a in (%temp%\Myfile.csv) do (
set p1=%%a         .
set p2=%%b         .
set p3=%%c         .
set p4=%%d         .
echo !p1:~0,9! !p2:~0,9! !p3:~0,9! !p4:~0,9!

del %temp%\myfile.csv

Please come back & tell us if your problem is resolved.

Report •
Related Solutions

Ask Question