Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Fine if you always want to rename the same file. If you can say exactly what you want to do I daresay we can help with the script.
I happen to do this with batch files, so that various programs reset to my favoured setup next time they start.
Derek.W

I would appreciate it if you would show me how to create a batch file; I've never done it before. I'm relatively inexperienced at computers.

Creating a batch file is simplicity itself - you just use a text editor such as notepad or even DOS Edit and enter the commands you want executed - save the resulting file using the .BAT extension.
You have to have a fairly precise idea of what you hope to accomplish - generalities won't do.Braccae tuae aperiuntur

Here's an example from part of one of my own batch files.
I wanted to rename the file english.lng to english.dw (which is in the folder c:\program files\a2 free\languages)
To run it in Windows this was my batch file:
@echo off
ren "c:\program files\a2 free\languages\english.lng" "english.dw"
clsThe "@echo off" line just prevents it from repeating things in the DOS window (not essential). The cls at the end closes the screen when you exit from the batch file. There is no Return at the end of the batch file (cls in this case). The quotes tell it to recognise long folder/file names.
If I want this to run this from true DOS you can't use long file names anyway, so I don't need the quotes. Each long folder (directory) name or file name has to be reduced to 8 characters max using ~ symbol, followed by 1 unless there are other folders/files that would look the same when shortened. Here's the true DOS version:
@echo off
ren c:\progra~1\a2free~1\langua~1\english.lng english.dw
clsNOTE that the first example has wrapped around on here. Line two should not have wrapped around and there is one space after english.lng" as per the second example.
Maybe I should explain that tilda symbol part (~). Suppose that in one folder you had a file called "elephants trunk.doc" and in the same folder you had another file called "elephants tail.doc". When these are reduced to 8 characters in DOS then the two files would appear like this:
elepha~1.doc
elepha~2.doc
This is necessary because you can't have two files with the same name. Note that the DOS names are how the file is really known by the system (long file names are just for the convenience of us humans). If you want to know what the long file name world looks like then just type winfile in the Run box and hit Return key. What you see will be the short file name version of Windows Explorer (more correct than WE actually)
Once you have produced your batch file (which is nothing more than a series of DOS commands) then you save it in the form File.bat
If you want to run it from the desktop you can either put the file itself there or make a shortcut to it.
The trick with batch files is to understand DOS commands first. Then you put them one after the other and away you go.
We can help with the script but we would need to know the exact file name and path that you want to rename.
Derek.W

One recommendation Gary...learn about batch files in the manner Derek has it laid out. You'll soon be able to do a lot of work with a click or two.
You'll find programs available that will "write" a batch file for you. Stay very far away from that sort of thing; I can't make 'em work and I've been writing batch files for fifteen years.
Skip

Not the best way to learn but here it is, exactly the way
I said:
@echo off
ren c:\windows\hosts hosts.txt
cls
The only thing that is unusual is that hosts is one of the few files that has no extension.If you want one that changes it back again then it's this:
@echo off
ren c:\windows\hosts.txt hosts
cls
ren means rename. Note the space between the two file names. Nothing more than 8 characters, so no tilda's or quotes. Get the idea?Good luck
Derek.W

Batch files are employed to perform repetitive tasks with minimal effort on the user's part.
Renaming a single file once does not require a batchfile - just the DOS command:
ren c:\windows\hosts hosts.txt
Done
.. of course, you realize (I hope) that once renamed, that file will no longer perform its original function.
Braccae tuae aperiuntur

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |