create batch to change file extensions to uppercase

Posted on 2005-03-31
Medium Priority
Last Modified: 2012-08-13
i have over 5000 pdf files in one directory which are going to be part of pdf search for tool company i have created my database in mysql but i have noticed the PDF file extension are mixed some are uppercase and some are lowercase how would i create a simple batch file to change the file extension to uppercase.with in
i have never wrote a batch file so i would not know where to start.

Example: so if i had TX456.pdf i need the file changed to TX456.PDF
Question by:Darrennew
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1

Expert Comment

ID: 13674035
ren *.pdf *.PDF if all files are in current directory

Accepted Solution

fadloun earned 2000 total points
ID: 13674037
open notepad

rename *.* *.PDF

save it as rename.bat
copy it to ur directory and run it

Expert Comment

ID: 13674129
I assume you will use vb for creating the database.
So u can use

Dim cf As String, Path As String
Path = "C:\"
cf = Dir(Path & "*.pdf")
Do While Not cf = vbNullString
    Name Path & cf As Path & Left(cf, Len(cf) - 3) & "PDF"
    cf = Dir
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 19

Expert Comment

ID: 13674351
...and what if someone adds a new pdf file, and the extention would be in lower case rather than upper case? Would you run the batch again?

That is why in VB we have the LCase or UCase functions, as in:

MsgBox UCase("Darrennew") will return DARRENNEW

In addition, databases have the UPPER function to do the same.

So, what you need to do is the make sure that each time you are looking for a filename, either in the database or in the folder, to prefix it with UCase function or UPPER function. If you do that, then you don't need to replace the file extentions with upper case extentions.


Expert Comment

ID: 13674398
anyway. accessing files is not case sensitive. so i dont think there is a need for changing the case of files expect for visual purpose. I guess
LVL 19

Expert Comment

ID: 13674433
<< accessing files is not case sensitive >> 
Locally, files are not case sensitive, however, remotely, they might be.


Expert Comment

ID: 13674469
Yes, you are right,
Renaming a file is not advisable. better to store the filename as it is.
LVL 19

Expert Comment

ID: 13674533
Yeh, I agree.


To illustrate my previous post, here is an example of how to use the UCASE and UPPER functions:

yourRS.Open "SELECT * FROM yourtable WHERE UPPER(fieldfilename)='" & UCase(variablefilename) & "';", yourConn, adOpenKeyset, adLockReadOnly


Expert Comment

ID: 13674694
I think the asker should mention to purpose of his question so experts could give him the solution he is looking for quickly
( maybe this solution is never come to asker's mind and it is faraway of a question has been asked)

Author Comment

ID: 13675344
Sorry what can I say I have never had so many responses in such a little time am very sorry if I did not explain myself what I was after was simple bat file to change file extension within a windows directory so save me changing them manually one by one.

Now I change the extensions to uppercase I can ftp them up to my Linux server.

I have already setup the database using a Perl script called power seek search engine I imported all my http links to point to my PDF library but because the PDF links where uppercase it was causing the link to be dead

Now when I do a search on product I can now click on link and points me to PDF file and the link opens can

I would like take this optunity to say thank you to every body for all your help
With out expert-exchange and all the experts that share there knowledge with us newbie’s we would not be able too do half the things we do.

I finally use the this suggestion from Fadloun
Rename *.* *.PDF which worked a treat.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question