Home / Microsoft / Microsoft DOS / [solved] Create 100 files in a folder
0 Members and 2 Guests are viewing this topic. « previous next »
Pages: 1 2 [All] - (Bottom) Print
Author Topic: [solved] Create 100 files in a folder  (Read 1958 times)
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« on: August 22, 2009, 03:31:52 AM »

Create 100 files in a folder

I need create 100 files in a folder.
The bat may ask the path of the folder. Create if not exists. Proposing the last one used.

The files to create have this structure : prefix.800.bat , where 800 take values from 800 to 899 .

The bat may ask the prefix. By example : pepe

The content of the bat files is slightly different

The general content is :

echo off
taskkill.exe /im gmw5.exe /f
Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\prefix.800
exit


Where prefix = pepe
and 800 goes from 800 to 899 corresponding to the name of the bat

That is : pepe.800.bat -> pepe.800

....................................... ................
              pepe.899.bat -> pepe.899

******************************

The bat procedure :

1. Ask for the path where the 100 files will be.
2. Ask for the prefix
3. Generate the 100 files....


thanksssxxx
« Last Edit: August 22, 2009, 01:02:30 PM by Esgrimidor » IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
smeezekitty
Newcomer



Thanked: 44
Posts: 0


« Reply #1 on: August 22, 2009, 11:25:52 AM »

empty files?
what do you want the files to contain?
IP logged

Acer extensa 463oz
2 gb ram
160gb hdd
2ghz processor
and desk fan sitting next to it for cooling :)
BatchFileBasics
Hopeful



Thanked: 18
Posts: 387


BatchFileBasics
« Reply #2 on: August 22, 2009, 11:27:26 AM »

so, are you asking to create files
pre.800 - pre.899?

no .bat ext?

Code: [Select]
@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a >>%pr%.%%a
echo exit>>%pr%.%%a
)
IP logged

When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« Reply #3 on: August 22, 2009, 11:57:39 AM »

empty files?
what do you want the files to contain?



"The files to create have this structure : prefix.800.bat , where 800 take values from 800 to 899 ."

So are bat files.


By example : pepe.800.bat have this content :

echo off
taskkill.exe /im gmw5.exe /f
Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\pepe.800
exit

and pepe.801.bat have this :

echo off
taskkill.exe /im gmw5.exe /f
Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\pepe.801
exit

and so on to the value 899 .

"so, are you asking to create files
pre.800 - pre.899?

no .bat ext?"

extension .bat


*********
I try again :

I need generate 100 bat files

prefix.800.bat to prefix.899.bat where prefix is a variable. By example prefix=pepe

Each bat file have a similar content, only vary the archive prefix.800 where 800 vary from 800 to 899.

prefix is a variable. By example prefix=pepe


by example :
The file pepe.850.bat have this content :

echo off
taskkill.exe /im gmw5.exe /f
Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\pepe.850
exit

Thanksxxx




IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #4 on: August 22, 2009, 12:00:28 PM »

Quote from: I try again :
I try again :

 ::)
IP logged


Proud to be European
BatchFileBasics
Hopeful



Thanked: 18
Posts: 387


BatchFileBasics
« Reply #5 on: August 22, 2009, 12:04:53 PM »

ok, sorry, the
Quote
Where prefix = pepe
and 800 goes from 800 to 899 corresponding to the name of the bat

That is : pepe.800.bat -> pepe.800

....................................... ................
              pepe.899.bat -> pepe.899

so let me do this again  ::)

Code: [Select]
@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a.bat
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a.bat >>%pr%.%%a.bat
echo exit>>%pr%.%%a.bat
)
IP logged

When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« Reply #6 on: August 22, 2009, 12:05:49 PM »

I try the script.

I think is going well. Now comment.
IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« Reply #7 on: August 22, 2009, 12:07:41 PM »

I comment on the first one :

I can't paste in the command window the path I want .

It's possible prepare this ?

I try the second.
 ::)
IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« Reply #8 on: August 22, 2009, 12:09:30 PM »

::)



You are quite right. I only try to reproduce a script.
IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
BatchFileBasics
Hopeful



Thanked: 18
Posts: 387


BatchFileBasics
« Reply #9 on: August 22, 2009, 12:10:10 PM »

are you pressing ctrl + v? because that does not work.

right click the window > paste.

or you can just type it in manually
IP logged

When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« Reply #10 on: August 22, 2009, 12:16:04 PM »

Okis.


The files are created in the present folder not in the folder indicated.

I try with Y:\prueba , but the files were written in the dektop folder in :

M:\Documents and Settings\JOSE\Escritorio\

IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
BatchFileBasics
Hopeful



Thanked: 18
Posts: 387


BatchFileBasics
« Reply #11 on: August 22, 2009, 12:17:19 PM »

oh my, i should of fixed that,  :P

Code: [Select]
@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd /d "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a.bat
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a.bat >>%pr%.%%a.bat
echo exit>>%pr%.%%a.bat
)
IP logged

When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.
BC_Programmer
Mastermind


Thanked: 697
Posts: 15,881

Computer: Specs
Experience: Beginner
OS: Windows 7


Pinkie Pie is best pony

BC-Programming.com 1 1
« Reply #12 on: August 22, 2009, 12:18:56 PM »

I'm trying to understand why multiple batch files are even necessary.
IP logged

My Blog

BASeBlock 2.3.0 (NOW WITH MACGUFFINS!)
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« Reply #13 on: August 22, 2009, 12:21:57 PM »

oh my, i should of fixed that,  :P

Code: [Select]
@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd /d "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a.bat
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a.bat >>%pr%.%%a.bat
echo exit>>%pr%.%%a.bat
)

Inside each bat file created I observed you put the extension bat to the files inside. And ther is not extension there.


That's :

pepe.850.bat

have the content :

echo off
taskkill.exe /im gmw5.exe /f
Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\pepe.850
exit

In this case don't have the extension bat inside........

IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
BatchFileBasics
Hopeful



Thanked: 18
Posts: 387


BatchFileBasics
« Reply #14 on: August 22, 2009, 12:25:01 PM »

Esgrimidor, what do you need 100 batch files for anyways? 1 file, about 10 lines, and a good for loop can probably do what all these files would do..

and really, this is confusing me,
here you go
Code: [Select]
@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd /d "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a.bat
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a >>%pr%.%%a.bat
echo exit>>%pr%.%%a.bat
)
IP logged

When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« Reply #15 on: August 22, 2009, 12:26:59 PM »

I'm trying to understand why multiple batch files are even necessary.

Is for my program Goldmine 5.5 from Frontrange.

This program make macros with the structure   user.800 .... user.899

When I launch from the exterior a user.800.bat ...... user.899.bat I'm launching the program with my parameters and a specified macro.

In this way

user.860.bat launch

echo off
taskkill.exe /im gmw5.exe /f
Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\user.860
exit

P.D. Each macro goes o search for a certain field in the database. So is equivalent to enter Goldmine and go to the field determined by the interior macro.....

I hope is understood.

Thanksxxxx

IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« Reply #16 on: August 22, 2009, 12:34:13 PM »

I'm trying to understand why multiple batch files are even necessary.

Well.
I use excel 2002 and have a check list. I would like to link this list with certain contacts in the database.
Each bat is used to link to a contact predetermined with a internal goldmine macro.

In an excel cell I put the path to the bat :  <path>\pepe.800.bat

Each bat execute the program goldmine and a internal macro , and goes to a predetermined contact in the database. And edit that contact.

I hope this is understood.

I have to make one internal macro for each contact to search.

And one corresponding bat for each internal macro.

The internal macro have the structure   pepe.800
and the bats have the structure  pepe.800.bat

....



IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« Reply #17 on: August 22, 2009, 12:40:48 PM »

Esgrimidor, what do you need 100 batch files for anyways? 1 file, about 10 lines, and a good for loop can probably do what all these files would do..

and really, this is confusing me,
here you go
Code: [Select]
@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd /d "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a.bat
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a >>%pr%.%%a.bat
echo exit>>%pr%.%%a.bat
)


Please tell me if this modification is correct or not :

Code: [Select]
@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd /d "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a >>%pr%.%%a
echo exit>>%pr%.%%a
)
IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
BatchFileBasics
Hopeful



Thanked: 18
Posts: 387


BatchFileBasics
« Reply #18 on: August 22, 2009, 12:41:24 PM »

sorry, i mean the extensions it is being output to is not in bat

following your..."requests"

this is it:
Code: [Select]
@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd /d "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a.bat
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a >>%pr%.%%a.bat
echo exit>>%pr%.%%a.bat
)
IP logged

When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« Reply #19 on: August 22, 2009, 12:47:07 PM »

Of course you are right

Sure there are a lots of ways of doing this : DDE, API Goldmine, COM procedures, etc.
But in the goldmine forum , at the present moment, they don't give support for via VB create an script for seek a record in the database without need to open goldmine.

This way is one of many ways, and for me is enough.

Thank very much.

100 is the number of macros you can create with a user. Each user can have 100 macros. And the user JOSE can use the macros of other users......

In this way I can have all the links I need from excel, word.

To make "fussions" Goldmine have an utility : gmlinks I use to prepared personalyzed writes....













IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« Reply #20 on: August 22, 2009, 12:55:01 PM »

sorry, i mean the extensions it is being output to is not in bat

following your..."requests"

this is it:
Code: [Select]
@echo off
:begin
set pth=
echo.
set /p pth=Path of folder:
if not exist "%pth%" (
mkdir "%pth%"
goto :PRE
)
echo.
echo ERROR: Folder exists
goto :begin
:PRE
set /p pr=Prefix for files:
echo.
echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
pause
cd /d "%pth%"
for /l %%a in (800,1,899) do (
echo @echo off>%pr%.%%a.bat
echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a >>%pr%.%%a.bat
echo exit>>%pr%.%%a.bat
)



I see.....

How can I do bat files pepe.800.bat and inside the bat : pepe.800 only ?

 
IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
BatchFileBasics
Hopeful



Thanked: 18
Posts: 387


BatchFileBasics
« Reply #21 on: August 22, 2009, 12:56:58 PM »

thats what it is, they are all .bat files.
but inside are just pre.800
no .bat inside
IP logged

When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.
Esgrimidor
Topic Starter
Intermediate



Thanked: 1
Posts: 205


« Reply #22 on: August 22, 2009, 01:00:09 PM »

Oh yes.

Perfect. Is enough for me.
You have saved me a lot of work.
With the bats is another thing....

IP logged

No dejes que tu felicidad dependa de lo que no depende de tí.
smeezekitty
Newcomer



Thanked: 44
Posts: 0


« Reply #23 on: August 22, 2009, 01:24:59 PM »

Code: [Select]
@echo off
set /p prefix=Enter Prefix:
for %%d in (0, 1, 100) do (
set /A i=%%d+800
taskkill.exe /im gmw5.exe /f
Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%%prefix.%%i.bat
)
exit
IP logged

Acer extensa 463oz
2 gb ram
160gb hdd
2ghz processor
and desk fan sitting next to it for cooling :)
Pages: 1 2 [All] - (Top) Print 
Home / Microsoft / Microsoft DOS / [solved] Create 100 files in a folder « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.134 seconds with 19 queries.