Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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
  • 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

580 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