Computing.Net > Forums > Programming > Batch File Formmatting Help, Please

Batch File Formmatting Help, Please

Reply to Message Icon

Original Message
Name: bluetitan
Date: March 5, 2006 at 00:58:47 Pacific
Subject: Batch File Formmatting Help, Please
OS: WinXP
CPU/Ram: 3.2ghz/ 2.0g ram
Model/Manufacturer: HP
Comment:

Hi Batch Experts,

I have a batch file that (on exec) prints all the files (filename.ext only) in the current dir to a notepad and saves the txt file to the same dir.

Example Text format:
--------------------
dir.bat
test.jpg
test2.jpg
test3.jpg

I need my batch to function so that the txt file created looks like the following:

&imgV=dir.bat,test.jpg,test2.jpg,test3.jpg&


Here is the code from my current batch file:
@dir %1 /-p /o:gn /b > ".\dir.txt"


Thank you in advance for your help!!!


Report Offensive Message For Removal

Response Number 1
Name: Mechanix2Go
Date: March 5, 2006 at 02:05:15 Pacific
Subject: Batch File Formmatting Help, Please
Reply: (edit)

First, it's a bad idea to name a BAT the same name as any internal command or reserved word.

Next, the /-p is superfluous because the default is to not pause.

This desired output:

&imgV=dir.bat,test.jpg,test2.jpg,test3.jpg&

would entail several things.

[1] Stripping out "line breaks"
[2] Adding commas
[3] Adding the enclosing &

There are probably very few contributors here slick enough to do this in a BAT. Sadly, I'm not one of them.

I'll work on a script which uses a 3rd party utility. Meanwhile we'll wait for IVO, FM, dtech10, et al.


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: March 5, 2006 at 02:42:56 Pacific
Subject: Batch File Formmatting Help, Please
Reply: (edit)

Try this, after getting CHANGE:

Here

:: == dir2txt.bat
@echo off
echo head> some.txt
dir %1 /o:gn /b >> some.txt
echo tail>> some.txt
change some.txt 13,10 ","
change.com some.txt "head," "&imgV="
change.com some.txt ",tail," "&"
:: DONE



If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 3
Name: bluetitan
Date: March 5, 2006 at 11:17:03 Pacific
Subject: Batch File Formmatting Help, Please
Reply: (edit)

Thank you Sooo Much for your help(and quick response!!!) That worked AWESOME!!! It appears you were slick enough....



Report Offensive Follow Up For Removal

Response Number 4
Name: Mechanix2Go
Date: March 5, 2006 at 13:26:02 Pacific
Subject: Batch File Formmatting Help, Please
Reply: (edit)

Thanks,

I wouldn't know how to get a BAT to handle the & because it has "special meaning".

Glad that helped.


If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch File Formmatting Help, Please

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software