# Batch renaming and creating file : DOS



## suBz3ro (Aug 9, 2006)

Have problem here.

i want to batch creating .png using DOS file if possible.
Scenario is like this.

i have list of filename. then i want to make png file from each of the filename
for example

test1.txt --> text1.png
test2.txt -->text2.png
hithere.txt --> hithere.png

and so on.

*all .png file context same image on it.

thanks

*http://www.gothlair.net*


----------



## JohnWill (Oct 19, 2002)

You just want to rename a bunch of TXT files to PNG files? Or do you want to do a graphics conversion from the text format to a graphics format? If it's just a rename, try:

REN *.TXT *.PNG

Job done.  Obviously, if you want to do a graphics conversion, you need a program to do the job.


----------



## suBz3ro (Aug 9, 2006)

thanks for your replied.

my question is using filename string list to make a .png for each of the filename string.

name1
name2

so on.
*its a string.

so want to create .png file from each of the string
name1 --> name1.png
the .png is from a default image, all .png files that created will have same image but different filename according to the filename list string


----------



## ChuckE (Aug 30, 2004)

I am not positive of what you just wrote, but here is what I think you meant:
"I want a tool that will read a text file of assorted image filenames and convert each image into PNG format."
Is that right?

If so, I would use IrfanView, but IrfanView does not have (that I am aware of) the ability to read a textfile of filenames and convert each.

However you could make a batch file to copy the desired images into a particular temp folder, and still within that batch file, to command IrfanView to convert the whole of that temp folder and place the resulting PNG files wherever you want, then finally delete the temp folder.

It is a bit more involved than what I believe you asked for, but workable.

By the way, I have sent a request off to Irfan Skiljan (the creator of IrfanView) to add a textfile reading/conversion ability. If more people also send him that same sort of request then he will see that it is a desirable feature request.
See his webpage for his email address.


----------



## suBz3ro (Aug 9, 2006)

thanks bro.

What i'm try to do is generate .png file from list of strings (echoing from php)

example 
Deicide - Bible Basher
Deicide - Scars_Of_The_Crucifix
Dimmu Borgir - Progenies Of The Great Apocalypse

each generated .png file will named as the string.
Generated png file will have same width and height resolution.

outcome
Deicide - Bible Basher.png
Deicide - Scars_Of_The_Crucifix.png
Dimmu Borgir - Progenies Of The Great Apocalypse.png


----------



## ChuckE (Aug 30, 2004)

Sub0 you need to answer some questions, if you expect some useful answers.
I asked you if you already have existing image files. Just having a list of strings will not be adequate to create a PNG (which is, and please correct me if I am wrong here, you mean a Portable Network Graphic).

If you already have some graphics, what format are they (the 3 character file extension) ?
If all you want to do is add the ".PNG" to the end of existing PNG files that don't have an extension, there are simple ways of doing that.
If all your graphics are in some other image format, and you want to convert them all to PNG, with some size restriction, then tell us that.
And that too, is an easy task for IrfanView.

You are not giving any reason of why you want to work with this "list of strings"

In your original message you said "all .png file context same image on it" ???
Are you saying all you want to do is copy and rename an existing image?

Need some answers.


----------



## suBz3ro (Aug 9, 2006)

thanks bro.

maybe my questions there a bit confuse and hard to understand,my bad.
i dont have any graphic. but i will create a default one (png or any image extension)

what i have in mind is a batch tool or program that will read list of string (string and without any format) then create a png file according to the string list itself and end with png extension.The process will create same png image for png image that i have created. (sharing the same image content but different filename)

process is like 
this list of string ---> automaking png file according to string list(only 1 png file but different name)


----------



## Squashman (Apr 4, 2003)

I have been following this thread and I am still confused.


----------



## JohnWill (Oct 19, 2002)

I think I get it.

He has one PNG file, let's say it's named SAMPLE.PNG

He has a text file with a bunch of file names, let's say the contents are.

filename1
filename2
filename3

He wants to run a job that will copy the SAMPLE.PNG to each of the file names in the file, in this case he'd end up with

filename1.png
filename2.png
filename3.png

Each of the proceeding files would be a copy of SAMPLE.PNG

*Is that it?*


----------



## Squashman (Apr 4, 2003)

That Makes Sense Johnwill. So, I went searching and stumbled on this thread.
http://answers.google.com/answers/threadview?id=711895

I then downloaded this tool.
http://www.hammerdata.com/Google/hdsFileDup.exe


----------



## JohnWill (Oct 19, 2002)

Well, he has a list of names in a file, so it's not exactly the same process. Or at least, I think that's what is intended here...


----------



## Squashman (Apr 4, 2003)

JohnWill said:


> Well, he has a list of names in a file, so it's not exactly the same process. Or at least, I think that's what is intended here...


Ah, yes, I see your point. The filenames aren't consecutive. I could do this real easy with a Bash script but I never really did get into Batch files much. I am trying to learn the new PowerShell but haven't had much time.


----------



## suBz3ro (Aug 9, 2006)

JohnWill said:


> I think I get it.
> 
> He has one PNG file, let's say it's named SAMPLE.PNG
> 
> ...


you hit the jackpot!.
thats what i'm trying to say.
any help or link where i can get help from?


----------



## dtech10 (Jan 31, 2003)

Somthing like this do, if you're using WinXP ,Win2000

@echo off
for /f %%a in (Names.txt) do copy Sample.png %%a.png


----------



## ChuckE (Aug 30, 2004)

Good solution *dtech10*, but there is a slight problem with the possible spaces, such as *sub0*'s example of:
_Dimmu Borgir - Progenies Of The Great Apocalypse_

So, I propose a slight alteration of:

```
@echo off
for /f "delims=~" %%a in (Names.txt) do copy Sample.png "%%a.png"
```
*Sub0*, this allows spaces to be included in the text sent through to naming the .Png file. The quotes, after the _COPY_ command, are there to ensure that those spaces are maintained.

It also assumes that the tilde character (~) is NEVER used in any of your file names. If a tilde is there it will act like a "space" (the normal delimiter), and any text after that character will not be part of your to-be-created .png file. 
So, if the tilde is not the best character to use (best: being never used in any of your strings), then you should find out what other character you can use, and place it where the tilde is here.


----------



## suBz3ro (Aug 9, 2006)

thanks for the support.
have problem while running the .bat script.

@echo off
for /f "delims=~" %%a in me.txt do copy noimage.png "%%a.png"

error message appear.
me.txt used was incorrent.

my me.txt file look like this

Nightwish - nemo
nightwish - over hills and far away
Nightwish - Sleeping Sun
and so on.


----------



## ChuckE (Aug 30, 2004)

You forgot the parens ( and ).

It should be:

```
@echo off
for /f "delims=~" %%a in (me.txt) do copy noimage.png "%%a.png"
```


----------



## suBz3ro (Aug 9, 2006)

thanks bro and others. its help!.


----------



## ChuckE (Aug 30, 2004)

If that resolves your issue, please mark this thread "Solved"


----------



## dtech10 (Jan 31, 2003)

Hi
if there's spaces in your names text file try this

@echo off
for /f "tokens=*" %%a in (Names.dat) do copy Sample.png "%%a.png"


----------



## ChuckE (Aug 30, 2004)

So, you don't have to send a 2nd message. Just edit your input.

It makes for an easier read, and understanding, if you just make the input right, rather than to tell someone what you forgot to do (and hope they know how to edit your 1st input).


----------



## blaqDeaph (Nov 22, 2005)

ChuckE said:


> Good solution *dtech10*, but there is a slight problem with the possible spaces, such as *sub0*'s example of:
> _Dimmu Borgir - Progenies Of The Great Apocalypse_
> 
> So, I propose a slight alteration of:
> ...


Just a quick question, why the delims=~, shouldnt the quotes do the job fine?


----------



## ChuckE (Aug 30, 2004)

The *for /f* is searching through each line of the named file, and parsing per token. A token is separate by the delimiters, which is defaulted to 'white space' (can be a series of the actual space character or a series of tabs). Since each line may be made of a number of words and as many (minus one, of course) spaces, you need to change that default delimiter to some other character, which I specified to the "~" character, or as *dtech10* specified as "*"

Either will work. I tend to avoid wildcard characters, because it can be troublesome in some parsing situations, but in this instance it is just as usable for a substitute character.

The quotes you are looking at are used to keep the result all together in the renaming portion of that command.

So, we are needing to deal with spaces in two points here.
1) the delims keeps the spaces in the search process, and
2) the quotes keep the spaces in the naming process.


----------



## blaqDeaph (Nov 22, 2005)

Cool, thanks for the replies guys!


----------

