Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

Renaming files

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
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richard Korts

ASKER

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.
Avatar of Bill Prew
Bill Prew

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
can you explain the solution  further? with explanation of %% and ~ and A and what each is doing.
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

thank you so much for the explanation.
Very welcome.

~bp