Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Bat file remembers file name??

Original Message
Name: mholden58
Date: June 18, 2005 at 17:06:00 Pacific
Subject: Bat file remembers file name??
OS: windows xp
CPU/Ram: dont know
Comment:
Hi I have had no luck with this question on the xp forum, maybe someone here can help. I used to dabble with bat files 15-20 years ago, but am really rusty now.
Is it possible for a bat file to extraxt the filename from a randomly named file that always has the same extension lets say random.hex, save it it some way, and then rename a different file random_cks.hex.
Please bear in mind I want it to find the randomly named file, (which will be the only .hex in that particular directory)I don't want to type in the name of the file.
Thanks in advance, any help appreciated.
Martin.


Report Offensive Message For Removal


Response Number 1
Name: jboy
Date: June 18, 2005 at 18:11:30 Pacific
Subject: Bat file remembers file name??
Reply: (edit)
Really? - don't seem to see it here.

I'm not sure that I understand what you want this batch to do, but bear in mind that WinXP has no true DOS, but a command line emulation which uses an 'extended' command set - one of the very reasons for the message "This forum is for all Standalone versions of DOS, not the "DOS" prompt contained inside later versions of Windows."

Suggest reposting again in WinXP or else maybe Programming

Life is hard; it's harder if you're stupid. -John Wayne


Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: June 19, 2005 at 00:38:02 Pacific
Subject: Bat file remembers file name??
Reply: (edit)
This will work in NT, but NOT in DOS:

::** RENhex.bat
for /f %%H in ( 'dir/b *.hex' ) do ren %%H %%~nH_cks.hex

M2


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


Report Offensive Follow Up For Removal

Response Number 3
Name: mholden58
Date: June 19, 2005 at 02:21:29 Pacific
Subject: Bat file remembers file name??
Reply: (edit)
Thanks M2.
It is there, jboy, but seems to have died, it's on page 2.

M2, (or any other guru's out there.)
I ran a test with your script, it works for renaming a .hex file.
Problem is I need to take it a step further.
I need to sort of separate it out into two parts.
I'll give more detail: The parts in lower case work already, the parts in upper case are the parts I need help with (I'm not shouting!)
I move a meaningfully named (but it's always different) hex file into a directory.
I THEN WANT TO SAVE THE FILENAME IN SOME WAY
I then have to change it to another name (newhex.hex) so another batch file can process it. The batch file outputs a new file with another fixed name (crunched.hex)
I then delete the original file (newhex.hex)
I THEN WANT TO RENAME THE NEW FILE (always called crunched.hex) WITH THE FILENAME SAVED FROM THE ORIGINAL FILE. I can then use the script above to add the _cks suffix.

Eagerly waiting input from people far cleverer than me.
Thanks again for helping.
Martin.



Report Offensive Follow Up For Removal

Response Number 4
Name: Mechanix2Go
Date: June 19, 2005 at 02:39:53 Pacific
Subject: Bat file remembers file name??
Reply: (edit)
::** RENorig.bat
dir/b *.hex > origname.#
set /p origname=<origname.#

:: here's where you do the crunching

ren crunched.hex %origname%


M2


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


Report Offensive Follow Up For Removal

Response Number 5
Name: mholden58
Date: June 19, 2005 at 05:33:28 Pacific
Subject: Bat file remembers file name??
Reply: (edit)
What can i say?
M2, thanks very much indeed!
I ran a test and it works perfectly.
Thanks for taking the time to work out what I wanted.
isn't the internet wonderful!
Thanks again.
Martin.

Report Offensive Follow Up For Removal


Response Number 6
Name: Mechanix2Go
Date: June 19, 2005 at 05:43:59 Pacific
Subject: Bat file remembers file name??
Reply: (edit)
Hi Martin,

Yeah, the whole is greater than the sum of it's parts.

FWIW, the programming forum will accomodate most any script / batch question.

Enjoy.

M2


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


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: Bat file remembers file name??

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




Slow boot time

Trasnferring Documents from old HD

My k8T Neo-v usb's aren't working!

Date Modified = Date Created Time

system files on removable harddrive


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC