I'm trying to find a simple way to add a comma "," to the first line a group of files. The files are created daily and need be edited once created.
Meh, I'm bored and it's a slow Friday, so why not? Set fso = CreateObject("Scripting.FileSystemObject") For Each file In fso.GetFolder(".").Files If UCase(fso.GetExtensionName(file)) = "TXT" Then With file.OpenAsTextStream txt = Array(.ReadLine, .ReadAll) End With file.OpenAsTextStream(2).Write Join(txt, "," & vbNewLine) End If Next 'file
Today is my lucky day! This will save a ton of time, over, and over, and over... I really appreciate the help!
:: ===== script starts here ===============
::
:: patrick.bat 2012-08-25 16:01:30.37
@echo off > newfile & setLocal enableDELAYedeXpansioNfor /f "tokens=* delims= " %%a in ('dir/b *.txt') do (
set F=%%a
call :sub1 !F!
)
goto :eof:sub1
set N=
for /f "tokens=* delims= " %%i in (!F!) do (
set /a N+=1
if !N! equ 1 (
echo.%%i,
) else (
echo.%%i
)
)>> newfile
move /y newfile !F!
goto :eof
::====== script ends here =================
====================================
Life is too important to be taken seriously.M2
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |