Computing.Net > Forums > Programming > Batch Programming Help!

Batch Programming Help!

Reply to Message Icon

Original Message
Name: mander04
Date: January 31, 2008 at 05:28:02 Pacific
Subject: Batch Programming Help!
OS: xp
CPU/Ram: 1 gig
Model/Manufacturer: ibm
Comment:

I need to look in a folder and rename a randomly named file with the extension .ls to temp.ls It will be the only .ls file in the folder. I then want to execute a program that will encode the file. It will change the file name to temp.tp. I then want to change the file name back to the original name with the .tp file extension. I need help with the file name manipulation. Please help!

Mark.


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: January 31, 2008 at 05:43:45 Pacific
Reply: (edit)

@echo off > c:\files\my.ls
setLocal EnableDelayedExpansion

pushd c:\files

for /f "tokens=* delims= " %%a in ('dir/b *.ls') do (
set FN=%%~Na
)
echo ren !FN!.ls temp.ls
echo someprog.exe temp.ls
echo ren temp.tp !FN!.tp



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

M2



Report Offensive Follow Up For Removal

Response Number 2
Name: mander04
Date: January 31, 2008 at 06:51:09 Pacific
Reply: (edit)

I must be doing something wrong. My file is stored in c:\fanuc\temp The line for /f.... isn't taking the file name and putting it into !FN!.


Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: January 31, 2008 at 07:17:26 Pacific
Reply: (edit)


@echo off
setLocal EnableDelayedExpansion

pushd c:\fanuc\temp

for /f "tokens=* delims= " %%a in ('dir/b *.ls') do (
set FN=%%~Na
)
echo ren !FN!.ls temp.ls
echo someprog.exe temp.ls
echo ren temp.tp !FN!.tp


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

M2



Report Offensive Follow Up For Removal

Response Number 4
Name: mander04
Date: January 31, 2008 at 07:44:47 Pacific
Reply: (edit)

Thats what I have. No luck...


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: January 31, 2008 at 07:51:13 Pacific
Reply: (edit)

do this and post result:

dir/b *.ls


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

M2



Report Offensive Follow Up For Removal


Response Number 6
Name: mander04
Date: January 31, 2008 at 08:35:45 Pacific
Reply: (edit)

Under the C:\ nothing is there. I have the file in c:\fanuc\temp. If I do the dir there laser_1.ls displays.



Report Offensive Follow Up For Removal

Response Number 7
Name: mander04
Date: January 31, 2008 at 08:41:35 Pacific
Reply: (edit)

When I run the following line:

For /f "tokens...
It replies that
The system cannot find the file specified

I assume this is what you were thinking, and thats why you had me do the dir/b


Report Offensive Follow Up For Removal

Response Number 8
Name: mander04
Date: January 31, 2008 at 08:58:16 Pacific
Reply: (edit)

I got that to go away. I had a typo, sorry. Now there is no error, but it's not re-naming the file.


Report Offensive Follow Up For Removal

Response Number 9
Name: mander04
Date: January 31, 2008 at 09:12:03 Pacific
Reply: (edit)

I got it...

YOU ROCK!!

Mark


Report Offensive Follow Up For Removal

Response Number 10
Name: Mechanix2Go
Date: January 31, 2008 at 10:15:06 Pacific
Reply: (edit)

yeah, them typos will get ya every time



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

M2



Report Offensive Follow Up For Removal

Response Number 11
Name: eldhos
Date: February 1, 2008 at 08:31:12 Pacific
Reply: (edit)

Dear all please provide me a batch file to take the backup of the c drive to f drive

Pease help me


eldhos


Report Offensive Follow Up For Removal

Response Number 12
Name: Mechanix2Go
Date: February 1, 2008 at 16:27:15 Pacific
Reply: (edit)

That has nothing to do with this.

You need to start a new thread.


=====================================
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 Programming Help!

Comments:

 


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




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge