Romhacking.net

Romhacking => Newcomer's Board => Topic started by: Nyxos on May 29, 2013, 08:50:09 am

Title: [HELP] Batch File Creation
Post by: Nyxos on May 29, 2013, 08:50:09 am
Hello and Good Day,

I would like to create a batch file, wich I dont know how to make (n00b!). I am not much familiar on MSDOS Commands but on the contrary I only know a small portion of it.

The format would be this:

Legend: Program = prg, SourceFile = sf, Output = out

prog sf out

I would like to input a lot of source files "sf01.mp sf02.mp sf03.mp... and-so-on" that would retain their original filenames but with a "_dec" on the end of the filename. Thank You

Regards,
Nyxos
Title: Re: [HELP] Batch File Creation
Post by: BRPXQZME on May 29, 2013, 09:42:39 am
Normally you would write the for loop by hand on the command line to take care of the exact naming convention you want, as a throwaway. Well, you would if the shell were sane, which is pretty much exactly what the Windows/DOS shell is not. In a Unix-style shell this would easily be a one-liner. In bash, I would write:
Code: [Select]
for i in `seq -w 1 99`; do prog sf${i}.mp sf${i}_dec.mp
No such luck with the Windows shell; the required code is long and complicated enough you wouldn’t want to try doing this without putting in a file first (and I wouldn’t want to try wasting like 30 minutes writing the equivalent script such that it won’t break anything, being that I’m not sitting at a Windows box...). If it were very important that it run on an end user’s computer, that’d be another matter, but if it’s just for you I seriously urge installing something that’s going to make this go down better, such as MSYS (which comes with bash and would be a reasonably gentle introduction to Unix commands, a sort of gateway drug to being a full on command line warrior) or Windows PowerShell (which I personally know nothing about but everyone says it’s way better than the default so I’ll trust them on that one).
Title: Re: [HELP] Batch File Creation
Post by: Jorpho on May 29, 2013, 09:44:40 am
Are you running this in DOS, or in Windows?

Windows Vista and Windows 7 include a command called "FORFILES" which would be very useful in this case.
Title: Re: [HELP] Batch File Creation
Post by: Nyxos on May 29, 2013, 10:32:31 am
I am running Windows 7 (not mine) atm. I would like to run it. As stated on my main post I don't really have much knowledge on MSDOS.

Thank you for the codes BRPXQZME, but I require the code on MSDOS (Windows Shell), I don't possess a PC that can run a Virtual Machine to run the code on a Unix system for now (PC is slow as heck). As for Cygwin and Mysis, I don't want to install such programs on this PC cause its not mine, though I have them on my Laptop but my LT has a busted Backlight which in turn I cannot use :). Anyways thank you for the replies, though I really require that program :)

Regards,
Nyxos
Title: Re: [HELP] Batch File Creation
Post by: Jorpho on May 29, 2013, 10:41:49 pm
I would like to run it. As stated on my main post I don't really have much knowledge on MSDOS.
You can always learn.  ;D

FORFILES is ingeniously straightforward.  It looks like all you need is
Code: [Select]
FORFILES /c "cmd /c prog @file @fname_dec.@ext"
For every file in the current directory, this will run the command
Code: [Select]
prog [filename].[ext] [filename]_dec.[ext]
The alternative would be to throw something together with Excel (or some other spreadsheet) using its string-concatenation functions.  Ugly, but it works.
Title: Re: [HELP] Batch File Creation
Post by: Nyxos on May 30, 2013, 12:28:08 am
You can always learn.  ;D

FORFILES is ingeniously straightforward.  It looks like all you need is
Code: [Select]
FORFILES /c "cmd /c prog @file @fname_dec.@ext"
For every file in the current directory, this will run the command
Code: [Select]
prog [filename].[ext] [filename]_dec.[ext]
The alternative would be to throw something together with Excel (or some other spreadsheet) using its string-concatenation functions.  Ugly, but it works.

Is this the code?
Code: [Select]
FORFILES /c "cmd /c prog @file @fname_dec.@ext"
i would like to run the program through all the files with a extension .fv and then the output files would have a *_dec.fv added to their filenames as the output, sorry for being a n00b at this ;D.

EDIT: Solved!
Figured it out myself with your format @Jorpho-san, here's what I did
Code: [Select]
FORFILES /p *path/folder of the sourcefiles* /c "cmd /c
progam.exe @file @fname_dec.@ext"

I thank you for helping me a lot.  :)

Regards,
Nyxos
Title: Re: [HELP] Batch File Creation
Post by: BRPXQZME on May 30, 2013, 06:29:00 am
Are you running this in DOS, or in Windows?

Windows Vista and Windows 7 include a command called "FORFILES" which would be very useful in this case.
AHA! Never heard of that one. Yes, that is a much better command; it just got added around the time I quit heavy Windows usage. m(_ _)m
Title: Re: [HELP] Batch File Creation
Post by: Nyxos on May 30, 2013, 06:46:59 am
AHA! Never heard of that one. Yes, that is a much better command; it just got added around the time I quit heavy Windows usage. m(_ _)m

I am also surprised that a command such as that exist xD or is it just me not knowing better xDxD. Thank you also for your help
Title: Re: [HELP] Batch File Creation
Post by: Auryn on May 30, 2013, 04:09:32 pm
Apart that putting "multifile rename" in google would teach you everything this guys told you,
you would had found many window (free) tools to do this. Here some examples:
http://www.efsoftware.com/mr/e.htm (http://www.efsoftware.com/mr/e.htm)
http://www.bulkrenameutility.co.uk/Main_Intro.php (http://www.bulkrenameutility.co.uk/Main_Intro.php)
http://www.advancedrenamer.com/ (http://www.advancedrenamer.com/)
Title: Re: [HELP] Batch File Creation
Post by: Klarth on May 30, 2013, 04:49:51 pm
Personally, I use Bulk Rename Utility since I don't need to change mp3 tags.  The GUI is a bit overwhelming at first.
Title: Re: [HELP] Batch File Creation
Post by: Nyxos on May 30, 2013, 07:50:42 pm
No, I didn't require any Batch Renaming Utility. I needed a Batch file to run my program through various files and output them as their generic filename with a *_dec added to it. Sorry for not making this clear.