Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2   Go Down

Author Topic: HELP....I need a batch file to create huge number of tga files from regiments.ini file or units folder....  (Read 724 times)

0 Members and 2 Guests are viewing this topic.

Whiskey_Sierra_972

  • Modder
  • member
  • Offline Offline
  • Posts: 6508
  • In memory of my beloved hero: Saburo SAKAI!

Hi mates!

I need your help....

I have finished the updating of the Regia Aeronautica units in our game....

I have added all Groups , Wings , Squadrons and some other units (still thinking to add the schools too)....

BUT

Now I need to create a lot of tga files (one each for every unit added)....plus modify in part others from 'standard' BAT list....

Unluckly I'm unable to write a simple batch file that should do this simple thing:

Take names of squadrons in folder A (please remember that those files haven't an extension) or from a text list like regiments.ini or similar and dulicate with these names a void tga (named null.tga) file as model file placed in folder B.

I know that this is a strange request but this can speed up the process to update of squadrons lists with easy because the procedure to create a lot of units is very tedious and the void tga files are required to avoid crazy badges appearance (for example many of my new units without a void unitname.tga show the KG2 badge).

Moreover this batch file could be used not only by me and the addition of new (historical or not) units could be done more quickly!

I don't know if this batch file can be done , and if it can be done , done with more or less simplicity....but I thank all you for the time you'll give to this topic!

All the very best to all!

walter
Logged

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6040

I just did a search and this was the first hit, which supplies a simple .bat file that will create empty files having the names from your list.

https://stackoverflow.com/questions/24726707/batch-files-create-files-based-off-a-list

If you need each file to have content, that's another matter... ;)
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

Whiskey_Sierra_972

  • Modder
  • member
  • Offline Offline
  • Posts: 6508
  • In memory of my beloved hero: Saburo SAKAI!

Thanks mate but as you said I need to clone the base tga for the badge (a tga with a 126x126x8bpp image that for void is only the alpha channel)....

I have asked also to AI but no joy....
Logged

Whiskey_Sierra_972

  • Modder
  • member
  • Offline Offline
  • Posts: 6508
  • In memory of my beloved hero: Saburo SAKAI!
Logged

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6040

Walter,
Haven't tried it, but a quick perusal of the code in the first reply seems promising to me. The person requesting the help there seems to have the same need as you do...
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23933
  • Taking a timeout
    • STFU

Unfortunately the task isn't as clear as it needs to be - for me :D

For this example, I take it that we are talking about squad definition files as found in the "Paintschemes/blue" folder for instance.
And I take it that you want the null.tga file from "Paintschemes/decals" to be copied to correspondingly named tga files according to the files without extension found e.g. in the "Paintschemes/blue", to some other folder, e.g. "Paintschemes/decals/blue".

Then this would be your script:
Code: [Select]
@echo off
REM This script is intended to be used to create "void" squadron insignia batches
REM by taking an input folder with squadron definition files (filenames w/o extension) from folder "X"
REM and copying the "null" TGA file from IL-2's "PaintSchemes/decals" folder to folder "Y", using
REM the names from the files found in folder "X", accordingly
REM
REM Calling convention:
REM create_squad_voids "<folder X>" "<folder Y>" "<path to null.tga>"
REM
REM e.g. create_squad_voids ./blue ./decals/blue ./decals/null.tga
REM
REM
REM The two folder parameters can use absolute or relative paths

if not exist "%~dpnx2" mkdir "%~dpnx2"
for %%i in (%~dpnx1/*.) do (
  copy "%~dpnx3" "%~dpnx2/%%~nxi.tga"
)

If the real task differs from what my crazy mind managed to read out of the OP, then please be a tad more specific on what you're intending to do.

]cheers[
Mike
Logged
Don't split your mentality without thinking twice.

Satanas

  • member
  • Offline Offline
  • Posts: 27

Hello.
Try this .

It's a Powershell script.
I wrote it under W10 pro, it will not work with W7 (previous version of powershell).

The script lists the files in a source directory, keeping only files without extensions.
Then it reads this list, uses the names stored there to rename the file null.tga as many times as there are lines in the list file and puts them with the extension .tga in the target directory.

The script is encapsulated in an .exe file, it has a graphical interface.
Unzip archive in a work folder.
Then launch exe, click on the buttons to open the folder selection windows and choose your source directory, choose  (or create) your target directory and the directory in which you have your null.tga file.
Finally click on the green button to start the process.

Sometimes (often??) antivirus software doesn't like powershell scripts. With Comodo, I have to create an exception for the script to work properly.

Hoping that's what you're looking for.

Satanas.
Logged

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6040

My ignorance is showing here...  ;)  Is Powershell built in to Windoze, or is it an external app?
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

Satanas

  • member
  • Offline Offline
  • Posts: 27

Yes, since W7 Powershell has been an integral part of Windows. v2 in W7 and v5 in W10.
In a way, It's a batch 'upgrade'. I find the syntax of the commands less rebarbative and it is easier to get an idea of their function.
The tool (Iexpress) used to transform powershell scripts (.ps1 file) into exe is also supplied with W10.
That's why I use it, so there's nothing more to install.
The advantage of transforming a .ps1 file into an exe is that you encapsulate everything you need to run it (the script itself, background image, additionnal files, etc...), so there's no headache.
The disadvantage is that antivirus programs often block operation, so you need to create an exception for the software to work.
I've only been learning to use Powershell for a short while (only 3 months), so my code isn't very clean, but I manage to get scripts to work.
Logged

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6040
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

Whiskey_Sierra_972

  • Modder
  • member
  • Offline Offline
  • Posts: 6508
  • In memory of my beloved hero: Saburo SAKAI!

Unfortunately the task isn't as clear as it needs to be - for me :D

For this example, I take it that we are talking about squad definition files as found in the "Paintschemes/blue" folder for instance.
And I take it that you want the null.tga file from "Paintschemes/decals" to be copied to correspondingly named tga files according to the files without extension found e.g. in the "Paintschemes/blue", to some other folder, e.g. "Paintschemes/decals/blue".

Then this would be your script:
Code: [Select]
@echo off
REM This script is intended to be used to create "void" squadron insignia batches
REM by taking an input folder with squadron definition files (filenames w/o extension) from folder "X"
REM and copying the "null" TGA file from IL-2's "PaintSchemes/decals" folder to folder "Y", using
REM the names from the files found in folder "X", accordingly
REM
REM Calling convention:
REM create_squad_voids "<folder X>" "<folder Y>" "<path to null.tga>"
REM
REM e.g. create_squad_voids ./blue ./decals/blue ./decals/null.tga
REM
REM
REM The two folder parameters can use absolute or relative paths

if not exist "%~dpnx2" mkdir "%~dpnx2"
for %%i in (%~dpnx1/*.) do (
  copy "%~dpnx3" "%~dpnx2/%%~nxi.tga"
)

If the real task differs from what my crazy mind managed to read out of the OP, then please be a tad more specific on what you're intending to do.

]cheers[
Mike

Thanks Mike for your help!

I try to explain better (I think you have anyway done what my donkey mind have badly traduced in english)

1) I have a made a lot of new units file (those have only a name without etension) and these could be now placed (for cloning) in a folder named Paintschemes/Blue
2) I have a single Alpha channel only named null.tga for a not showing emblem in folder Paintschemes/Decals
3) I run your batch and I got , in a sub folder Paintschemes/Decals/Blue (is this generated from the bat or I have to create it before run the bat?) , a serie of copies of the null.tga named with the names of the files from folder Paintschemes/Blue....

Is that right?

To use the bat:

IIUC....I have to:

1) Create the bat by copying your script in a text file and save it with .bat extension
2) Create folder Paintschemes
3) Put here the .bat
4) Create subfolder Blue with all the new unit files (ex. 100 file)
5) Create the subfolder Decals with the null,tga file
6) Create the sub/subfolder Paintschemes/Decals/Blue
7) run the bat
8 ) open the Paintschemes/Decal/Blue subfolder and FINALLY I'll find 100 cloned .tga with the 100 unit names

Have I understand and studied to make it work correctly?

Thanks again in advance for your help!
Logged

Whiskey_Sierra_972

  • Modder
  • member
  • Offline Offline
  • Posts: 6508
  • In memory of my beloved hero: Saburo SAKAI!

Hello.
Try this .

It's a Powershell script.
I wrote it under W10 pro, it will not work with W7 (previous version of powershell).

The script lists the files in a source directory, keeping only files without extensions.
Then it reads this list, uses the names stored there to rename the file null.tga as many times as there are lines in the list file and puts them with the extension .tga in the target directory.

The script is encapsulated in an .exe file, it has a graphical interface.
Unzip archive in a work folder.
Then launch exe, click on the buttons to open the folder selection windows and choose your source directory, choose  (or create) your target directory and the directory in which you have your null.tga file.
Finally click on the green button to start the process.

Sometimes (often??) antivirus software doesn't like powershell scripts. With Comodo, I have to create an exception for the script to work properly.

Hoping that's what you're looking for.

Satanas.

Thanks Santas for your help....should I put your little tool here too:

.....
2) Create folder Paintschemes
3) Put here the .bat
4) Create subfolder Blue with all the new unit files (ex. 100 file)
....

Or can you please explain how to build the folders and where to place your tool to have it working?

Sorry but in this kind of things I'm less able than an Australopithecus....
Logged
Pages: [1] 2   Go Up
 

Page created in 0.033 seconds with 25 queries.