Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Renaming files

Posted on 2012-04-10
7
Medium Priority
?
473 Views
Last Modified: 2012-04-10
I have received about 100 files from a customer, they are jpg images for storing on a web site. My computer is Windows XP. Also about the same number of pdf.

For whatever reason, they are named <filename>.jpg.jpg. The extension jpg is there twice. Same for the pdf's.

I tried using dos command line old "ren" command, like this : ren *.jpg.jpg *.jpg

It didn't work.

Is there some way to do all at once?

Thanks
0
Comment
Question by:Richard Korts
[X]
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
  • 2
7 Comments
 
LVL 58

Accepted Solution

by:
Bill Prew earned 2000 total points
ID: 37830582
At a command line you could do:
for %A in (*.jpg.jpg) do ren "%~A" "%~nA"
for %A in (*.pdf.pdf) do ren "%~A" "%~nA"

Open in new window

Or in a BAT file do:
for %%A in (*.jpg.jpg) do ren "%%~A" "%%~nA"
for %%A in (*.pdf.pdf) do ren "%%~A" "%%~nA"

Open in new window

~bp
0
 

Author Comment

by:Richard Korts
ID: 37830618
To billprew,

Great , that did MOST of them (but not all).

I noticed that the ones that DIDN'T get changed were either duplicates or had the letter "A" as part of the filename.

But that's a HUGE help.
0
 
LVL 58

Expert Comment

by:Bill Prew
ID: 37830623
The dupes make sense they would have failed.  Don't see any reason why having an A in the name would have caused a failure though.  Anyway, glad that helped.

~bp
0
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!

 

Expert Comment

by:jennifer636
ID: 37830802
can you explain the solution  further? with explanation of %% and ~ and A and what each is doing.
0
 
LVL 58

Expert Comment

by:Bill Prew
ID: 37830821
The tilde is used when referencing loop variables to alter the value that is substituted inline.

If you do FOR /? at a command prompt you can see what capabilities exist.  Here's an excerpt from that.

In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

    %~I         - expands %I removing any surrounding quotes (")
    %~fI        - expands %I to a fully qualified path name
    %~dI        - expands %I to a drive letter only
    %~pI        - expands %I to a path only
    %~nI        - expands %I to a file name only
    %~xI        - expands %I to a file extension only
    %~sI        - expanded path contains short names only
    %~aI        - expands %I to file attributes of file
    %~tI        - expands %I to date/time of file
    %~zI        - expands %I to size of file
    %~$PATH:I   - searches the directories listed in the PATH
                   environment variable and expands %I to the
                   fully qualified name of the first one found.
                   If the environment variable name is not
                   defined or the file is not found by the
                   search, then this modifier expands to the
                   empty string

The modifiers can be combined to get compound results:

    %~dpI       - expands %I to a drive letter and path only
    %~nxI       - expands %I to a file name and extension only
    %~fsI       - expands %I to a full path name with short names only
    %~dp$PATH:I - searches the directories listed in the PATH
                   environment variable for %I and expands to the
                   drive letter and path of the first one found.
    %~ftzaI     - expands %I to a DIR like output line

Open in new window

0
 

Expert Comment

by:jennifer636
ID: 37830917
thank you so much for the explanation.
0
 
LVL 58

Expert Comment

by:Bill Prew
ID: 37830923
Very welcome.

~bp
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
cPanel is a Unix based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides functionality for administrators, rese…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

618 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