Discussion Locked

How to globally change file names

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,
I would be grateful if anyone can tell me how to "globally" change file
names and folder names. I have some folder names and file names contain dots(.), spaces or other charactors that I want to get rid of. The trouble is that I have hundreds and hundreds of files and folders which need name changes, and I'm hoping there is a "global" way to do this instead of having to manually change each name one at a time. The System that I use is Windows NT.

folder name example: 1a.my folder rename to: 1a_my_folder
File name example: 4a.abc ddd.doc
rename to: abc ddd.doc

Thank you very much in advance for any help you can give!

Austin

9 replies

by lifeform2749

depending on the complexity of your name changes:

1. systematic name changes: use the (gasp) DOS ren command (works for folders and files); e.g. at a DOS prompt in the folder of interest, use a command like: ren nav?*.doc navj*.doc (this changes all files with extension "doc" and an arbitrary fourth character to navj*.doc); play around with the command a bit to see what it can do (for help, type ren /? at a DOS prompt.

2. for ad hoc changes (this also provides a record of the activity) use a DOS batch file that contains a series of DOS ren commands. This is easier than it might sound. You can use the DOS dir command piped to an output text file, then use an editor (preferably with MACRO capability to rapidly construct the DOSren commands). When you do this, you have a record of the name changes in the batch file. Piece of cake.....

by jay eckles

One more suggestions:

Perl was made for this sort of thing - you would build a regexp (regular expression) to search for filenames that don't conform to your specifications, then modify the name according to your rules. Your Perl program would then use that regexp while traversing a directory heirarchy you specify. It's a good beginner's project if you're new to Perl and don't mind learning a new language.

A great resource for Perl is http://www.perl.com.

Jay Eckles
www.jayeckles.com

by lo

You can list the files, DOS session, DIR {path & files here} >renfile.bat.

Use you favorite editor, preferably a programming one such as Emcacs, PFE, etc. that has macro ability.

Programming may be preferable as you have more control and it isreusable ( an editor should be a one shot (maybe two shor) process).

Any way you go, unless you can define some specific standards, its a lot of work.

Why the desire to change? Not accessable from an app, DOS, etc.?

You can get past that to some exten by quoting the path/file, if the app won't take 4a.abc ddd.doc use "4a.abc ddd.doc", if MS was going to allow imbedded spaces and such, they should changed the parser to accommoate, no?

by austin98

Thanks guys for your help. I have developed a VB software to solve this problem. I need to rename the file/folder names because I need to load the data to an existing SQL server database through an application and that application has restrict on the names. I found that DOS can change the names but it can only change the names folder by foler( I have numerous folders to process!). I have to run the script on a Windows NT system so I can not use PERL. The VB programming is very flexable. It alllows me to make changes on any charactors in any position and it allows me to do all the renaming work for mutiple folders and files by just one click.

Austin

This discussion is closed to new replies.