Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have seen many posts and they helped me alot, still I am facing a basic issue.
I am working on Win XP.I need a to create a batch file which takes inputs from a txt file, say
var1_address = D:\abc\some_address
var2_address = D:\xyz\some_address
var3_address = machine_name\path
var4_address = another_machine_name_path\some addressI want to take input from any of these paths and perfome below tasks
Ren var1_address *.zip
del var3_address\filename.zip
Problem:
1. I am unable to take all different addresses.
2. If I am able to take different inputs then I am unable to perform rename, delete kinda operations.
Please help me ASAP.Thanks
Sunny

Im not certain I follow.... I will try to help if you explain... Are the Commands stored in the Files? Or are you trying to perfom multiple tasks to different files, based on file name.... Please bear with me, I am a horrible communicator, especially when its through text.
I only Batch if possible, 2000 more lines of code, oh well.

Its ok.
Thanks for giving your time.Actually, I will write my commands in 1 batch file and take input of the path names from a txt file.
For example,
I will take remote machine name of server1 from text file name's variable "variable1" and perform command "ren variable1\*.* *.zip"So path only includes folder name that could be of a remote machine or local drive.
Am I able to understand my problem in better manner?

[1 If you want to set vars you need to use SET. [surprise]
[2] If you want to set var1 using the contents of one.txt:
set /p var1=<one.txt
[3] That will set var1 to the FIRST line of one.txt.
[4] You will want to be very careful with spaces in your SET because things can get very messy, very fast.
=====================================
If at first you don't succeed, you're about average.M2

this will set to the 1st line only
what if I have data in following format of txt file :
var1_address = D:\abc\some_address
var2_address = D:\xyz\some_address
var3_address = machine_name\path
var4_address = another_machine_name_path\some addressNow how will I get each variable in batch file to be used in commands?
Plz help

The last line is just to show wht was done.
===========================================
@echo off & setLocal EnableDelayedExpansionfor /f "tokens=* delims= " %%a in (my.txt) do (
set %%a
)set v
=====================================
If at first you don't succeed, you're about average.M2

Environment variable testing_location not defined
Environment variable v not definedThese are the errors I am receving.
testing_location is the variable name.
testing_location = \\machine_name\folder_nameSorry I am bothering you guys alot.

It might help if we had identical my.txt files.
Here's what's in mine.
====================================
var1_address=D:\abc\some_address
var2_address=D:\xyz\some_address
var3_address=machine_name\path
var4_address=another_machine_name_path\some
=====================================
If at first you don't succeed, you're about average.M2

Its not working for me...
throwing following error message
" Environment variable v not defined
v "what could the issue?

Like I said if we use the same text file and the same batch, we ight be able to troubleshoot it.
=====================================
If at first you don't succeed, you're about average.M2

Cool
I am able to get values BUT
I cant rename the file.What I mean, if
v = D:\abc\qwerty.txt
now i want to rename it to qwerty.zipren v qwerty.zip
ren &v% qwerty.zipnothing is working out.
I am not too much champ in batch files.
Sorry if I am doing anything silly.Please look into this small thing.

Assuming that you start your batch with:
@echo off
setLocal EnableDelayedExpansionAnd you have set a var named V to D:\abc\qwerty.txt
And you now want to USE the var to rename a file, try this:
ren !v!\qwerty.txt qwerty.zip
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |