Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Need help with creating a batch file  (Read 1332 times)

0 Members and 1 Guest are viewing this topic.

vibez

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 411
  • Last login:February 09, 2011, 08:33:20 am
  • I want to build my own arcade controls!
Need help with creating a batch file
« on: July 11, 2005, 02:53:44 pm »
Basically I have a program that needs to be run from a batch file or commandline.

It converts several files into 1 large one.

The format of the command line is (minus the brackets)

[output.qch] [input1.cod] [input2.cod] [input.3cod] etc....


I have a folder of about 1000 .cod files. I dont fancy typing that all out on a commandline.

Is there a way to create some batch file that will get the name of all the .cod files & feed it into a commandline like the one above? All the input.cod files need to be on one line

I tried

output.qch *.cod

but it moans about the *
« Last Edit: July 11, 2005, 03:06:11 pm by vibez »

NinjaEpisode

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 733
  • Last login:June 16, 2019, 06:47:45 pm
Re: Need help with creating a batch file
« Reply #1 on: July 11, 2005, 04:24:12 pm »
Is this Windows or elsewhere?

If windows, do the following:

In the directory that has the .cod files from a command line do:

dir /B *.cod >c:\filename.txt

Where filename.txt is the path/output file you want.

This will give you just a listing of the filenames.

Next, create a batch file with the following:

FOR /f "tokens=1 delims=;" %%l in (c:\filename.txt) DO output.qch %%l

although, I dunno if that'll work since I have not idea what a qch file is but this works very well for other purposes.
« Last Edit: July 11, 2005, 04:27:02 pm by NinjaEpisode »

vibez

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 411
  • Last login:February 09, 2011, 08:33:20 am
  • I want to build my own arcade controls!
Re: Need help with creating a batch file
« Reply #2 on: July 11, 2005, 04:38:35 pm »
Yes it is unders windows.

I get this error

"%%l was unexpected at this time."


Can I email you the files for you to test with?

vibez

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 411
  • Last login:February 09, 2011, 08:33:20 am
  • I want to build my own arcade controls!
Re: Need help with creating a batch file
« Reply #3 on: July 11, 2005, 06:06:20 pm »
Ok I have it almost working now :) :)

Only trouble is that it is not putting all the input.cod names on one line, but is feeding them to the program 1 at a time like the example below

FOR /F "tokens=1 delims=;" %l in (c:\filename.txt) do cod2qch output.qch %l

this is the result

C:\cod2qch output.qch input1.COD

C:\cod2qch output.qch input2.COD

C:\cod2qch output.qch input3.COD

C:\cod2qch output.qch input4.COD
« Last Edit: July 11, 2005, 06:08:20 pm by vibez »

NinjaEpisode

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 733
  • Last login:June 16, 2019, 06:47:45 pm
Re: Need help with creating a batch file
« Reply #4 on: July 11, 2005, 07:37:59 pm »
Oh I see.

Do you have MS Word?

Cut and past the list from the text file into MS Word.

Select Edit, Replace (Might be search & replace)

In the find section, input ^p

In the replace section, push your spacebar once.

Hit replace all.

This should take all the files and remove the return carriage and then put a space between each of them.

You can then cut and past into a new batch file with your call.

vibez

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 411
  • Last login:February 09, 2011, 08:33:20 am
  • I want to build my own arcade controls!
Re: Need help with creating a batch file
« Reply #5 on: July 12, 2005, 03:18:54 am »
Thanks ever so much. That worked perfect :)

Is there no way to modify the batch so we dont need the use a word editor?

NinjaEpisode

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 733
  • Last login:June 16, 2019, 06:47:45 pm
Re: Need help with creating a batch file
« Reply #6 on: July 12, 2005, 07:14:35 am »
There are all kinds of text editors that can detect and modify the special characters such as a carriage return.  As long as the editor can detect the formatting, you should be able to use what you like.  Word just came to mind because it's what I use regularly.

Scripting the whole thing is possible, but considering the amount of time it takes just to do a quick find and replace, I don't know that it's worth it.

vibez

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 411
  • Last login:February 09, 2011, 08:33:20 am
  • I want to build my own arcade controls!
Re: Need help with creating a batch file
« Reply #7 on: July 12, 2005, 09:03:10 am »
That is very true. I guess we dont even need the batch file once we have the filename directed to a text file. It just would of been nice if there was a way in dos to add each line from the text file into just one line.

Thanks again. Atleast you have saved me having to type out all the file names :)

Samstag

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1378
  • Last login:December 16, 2016, 01:41:19 am
  • That's not a llama!
Re: Need help with creating a batch file
« Reply #8 on: July 12, 2005, 09:12:52 am »
Download SimpleFileJoiner.exe.

Select all the files you want, select sort list (to make sure they're in alphabetical order), and select join.  Done!

vibez

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 411
  • Last login:February 09, 2011, 08:33:20 am
  • I want to build my own arcade controls!
Re: Need help with creating a batch file
« Reply #9 on: July 12, 2005, 10:32:16 am »
Download SimpleFileJoiner.exe.

Select all the files you want, select sort list (to make sure they're in alphabetical order), and select join.  Done!

Thanks but i'm not sure how that would help. The program I'm writing the batch for converts multiple files into a different format then encrypts them all into a big file. I don't think a file joiner is the answer here.

Although it does look like it will come in handy for other projects :)