Can anyone write this program for me please?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Kerr Avon
Posts: 29
Joined: 24 Dec 2014 11:00

Can anyone write this program for me please?

#1 Post by Kerr Avon » 30 Jan 2018 15:35

I'm hoping someone can put together a batch file for me that when ran, will look at every file in that folder that has an .z64 extension, and for each of those files, it will create a file called [the file name].eep, with the file being a copy of 1.eep (which is in the same folder).

What I mean is, say a folder contains:

1.eep
Infiltration Mission SP (Replaces Runway) .z64
Missile Facility Mission SP (Replaces Facility).z64
Nitro Surface Mission SP (Replaces Surface 2) .z64
Volcano Lair Mission SP (Replaces Caverns).z64


then when I run the batch file, then four new files will be created:

Infiltration Mission SP (Replaces Runway) .eep
Missile Facility Mission SP (Replaces Facility).eep
Nitro Surface Mission SP (Replaces Surface 2) .eep
Volcano Lair Mission SP (Replaces Caverns).eep


in the same folder, and each of these new *.eep files contain the same data as the file 1.eep. The reason is, the .z64 files are all modified versions of the N64 game, Goldeneye (each has a fan made mission edited into it), and to play these you need a save file that can unlock the mission (otherwise you have to play through the unedited missions to get to the edited mission in each .z64 file). The 1.eep file is a save file with everything unlocked, so I want a copy of this save file to use with every .z64 file, so each .eep file must be named the same as the .z64 file that will be using it.

The batch file should read the filename of each .z64 file in the folder (there are more than a dozen), and copy the file 1.eep to [the filename of the .z64 file].eep (i.e. create a copy of 1.eep and change the name of the copy to the same name as the .z64 file, but keep the .eep extension). The file 1.eep won't be changed, of course, but it will be copied and those copies will be renamed.

Also, it would be great if the two parameters of the batch file (the name of the file to be copied (in this case 1.eep). and the extension of the files that you want to have created (well, renamed from the copied name, in this case *.z64)) could be editable in the batch file, so anyone could use this batch file to do a similar operation but on files other than 1.eep, for example, if the user could edit the batch file to change

1.eep
*.z64

to

sentby.txt
*.doc

so that in this case, when the batch file is run then every file with a .doc extension would get a file of the same name, but with a .txt extension and the name of the .doc file, and the contents of the sentby.txt

Thanks for any answers.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Can anyone write this program for me please?

#2 Post by aGerman » 30 Jan 2018 18:14

Actually only one line of code.

Code: Select all

@echo off &setlocal
set "copyfile=1.eep"
set "searchext=*.z64"

for %%i in ("%copyfile%") do for %%j in (%searchext%) do copy "%%~i" "%%~nj%%~xi"
Steffen

Kerr Avon
Posts: 29
Joined: 24 Dec 2014 11:00

Re: Can anyone write this program for me please?

#3 Post by Kerr Avon » 01 Feb 2018 09:39

aGerman wrote:
30 Jan 2018 18:14
Actually only one line of code.

Code: Select all

@echo off &setlocal
set "copyfile=1.eep"
set "searchext=*.z64"

for %%i in ("%copyfile%") do for %%j in (%searchext%) do copy "%%~i" "%%~nj%%~xi"
Steffen
That is brilliant! It does exactly what I want, thanks mate!

Post Reply