Batch file, creating folders & FTP

March 30, 2009 at 22:20:57
Specs: Windows XP
Hello everybody...

I have some trouble making batch files...

I want to create if possible a batch file that creates folders given by a input file.

The structure of that input file (for example "test.txt") is:

column1 Column2
-------------------------------------
192.168.1.1 MyPC
192.168.1.50 MartinPC
192.168.9.250 AlexPC
...etc ...etc

The first column it's a IP, and the second it's the name of the PC.

I need to create folders with those names given as a parameter.

I know how to do if the folder name its a row [for /f %%A in (test.txt) DO (md %%A)], but I don't know how to do it if the parameter its the second column of a row.


Second Question

I need to FTP those PC's and transfer files to the created folders... how can I do that?

Sorry for my bad english...
Cheers, Javier


See More: Batch file, creating folders & FTP

Report •


#1
March 31, 2009 at 00:35:51
This will create folders on the local machine.

=============================
@echo off & setLocal EnableDelayedExpansion

for /f "tokens=2 delims= " %%a in (test.txt) do (
echo md %%a
)


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

M2


Report •

#2
March 31, 2009 at 04:32:36
Thank you so much Mechanix!

For the FTP part, I always use a file (example: MyPC.ftp) with the commands:

open 192.168.1.1
user
password
prompt
lcd c:\BACKUP\myPC
cd /folder/config
mget *.ini
quit

It is posible to create multiple files, modifying rows 1 and 5, adding the IP and the name of the PC? (the LCD folders have been created with the first batch)

So... If the folder list its:

column1 Column2
-------------------------------------
192.168.1.1 MyPC
192.168.1.50 MartinPC
192.168.9.250 AlexPC
...etc ...etc

I want to create multiple *.ftp files [Mypc.ftp; martinPC.ftp, etc --> yeah, the second column], and those *.ftp files have the IP (first row) and directory (LCD; fifth row):

myPC.ftp:
open 192.168.1.1
user
password
prompt
lcd c:\BACKUP\myPC
cd /folder/config
mget *.*
quit

MartinPC.ftp:
open 192.168.1.50
user
password
prompt
lcd c:\BACKUP\MartinPC
cd /folder/config
mget *.*
quit

I dunno if its possible to do it, thanks in advance

This batchs are to transfer more than 500 rtu's configs to a backup, and I always do it manually...


Report •

#3
March 31, 2009 at 04:56:30
@echo off & setLocal EnableDelayedExpansion

for /f "tokens=* delims=" %%a in (test.txt) do (
echo %%a
call :sub1 %%a
)
goto :eof

:sub1

> # echo open %1
>> # echo user
>> # echo password
>> # echo prompt
>> # echo lcd c:\BACKUP\%2
>> # echo cd /folder/config
>> # echo mget *.*
>> # echo quit

ftp -s:#

goto :eof


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

M2


Report •

Related Solutions

#4
March 31, 2009 at 18:07:14
Thanks a lot!!! Working great!

My best regards! Javier


Report •


Ask Question