Home / Microsoft / Microsoft DOS / [solved] Create 100 files in a folder
0 Members and 1 Guest 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.
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.107 seconds with 20 queries.