Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer audio black screen blue screen boot bsod computer connection crash css dell driver drivers email error ethernet excel explorer firefox firefox 3 hard drive internet internet explorer itunes laptop linux malware monitor network networking nvidia outlook outlook 2003 outlook 2007 outlook express partition problem router security slow software sound trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Batch File Question


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
jdach's Avatar
Junior Member with 4 posts.
 
Join Date: Dec 2004
Experience: Intermediate
17-Dec-2004, 10:38 AM #1
Question Batch File Question
I have command line exe file that converts one type of file (.sid) to another type (.jpg). It works well, but the only problem is it does not recognize wildcards, so I'm not able to convert many files at a time. Would it be possible to write a batch file that would somehow be able to populate the command line with each filename and the command for a given directory, thereby converting all files in a given directory?

Thanks in advance!
Squashman's Avatar
Distinguished Member with 12,689 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
17-Dec-2004, 12:12 PM #2
Lots of great links on google.

http://www.google.com/search?hl=en&q=batch+rename
drdrew1469's Avatar
Senior Member with 436 posts.
 
Join Date: Nov 2000
Location: PA
Experience: God
21-Dec-2004, 09:51 AM #3
If you want a simple 'batch file' you could use this instead of an exe.

-----------------
rename *.sid *.jpg
-----------------

Just put that in notepad, save it with a .bat extension and put it in the directory you want it to run in.

hth,

drew
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
21-Dec-2004, 01:21 PM #4
But he isn't renaming. I take it this is actually converting the files.

I am not a batch Guru but try something like this. Test on unimportant files first!

Copy the code below to notepad. Save as Copyit.bat


Code:
(
For %%A in ("*.txt") Do copy "%%A" Copies
)>>Report.txt 2>&1 

cls
To avoid a path statement, just put the batch into the same folder where you want to process files. For this example. Create a new Subfolder and name it Copies.

This will copy all txt files to the subfolder named Copies. It will also generate a report named report.txt with the results of the operation.

Report.txt will give you the name of the file and the status. 1 file copied.

Note the Parantheses. Without these around the command you would only get a list saying 1 files copied for each file. This gives you the name as well. I prefer it so we can doublecheck.

Substitute the name of your exe for copy when you do the real conversion. If that exe is in system32, Dos will find its path.


The 2>&1 is there so that any errors generated will be written to Report.txt as well. This assumes your program generates results.

Some do not. For example, if you use a batch to export a registry key using regedit, there is no feedback either good or bad if you redirect to a text file.
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
21-Dec-2004, 01:42 PM #5
This line:
)>>Report.txt 2>&1

That appends Report.txt so if you do it more than once in the same folder you have a complete record of all.

If you wnat to have just the results of the current run then change that line to this:
)>Report.txt 2>&1
drdrew1469's Avatar
Senior Member with 436 posts.
 
Join Date: Nov 2000
Location: PA
Experience: God
21-Dec-2004, 02:32 PM #6
Quote:
Originally Posted by Mosaic1
But he isn't renaming. I take it this is actually converting the files.
Good catch, I must have missed that (pretty important word that "converts)" That puts a damper on my solution. Hmmm...I'll have to think about this and try yours out. "Me brain hurt"

drew
drdrew1469's Avatar
Senior Member with 436 posts.
 
Join Date: Nov 2000
Location: PA
Experience: God
21-Dec-2004, 02:54 PM #7
Just had a thought, but no time to try it out right now, maybe someone else will post code for my thoughts before I can. Use an IF EXIST to look for *.sid. If it finds any, have it CALL your conversion program and pass the filename to it. Do a LOOP until there are none left. Anyone have any thoughts on this? I'll be back later.

drew
__________________
Please help me as I am attempting to (re)gain my (in)sanity.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 04:03 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.