Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I’m stuck on part of a batch file I’m working on. What I’m trying to do is copy all files with the extension JPE in a directory to another directory, adding “ (E-mail Size)” to the file name and making the extension lowercase. Therefore:
IMAGE01.JPE
becomes
X:\Path\IMAGE01 (E-mail Size).jpe
This batch file needs to work regardless of how many JPE files there are and what their names are. This is what I was trying:
IF EXIST *.JPE FOR %%A IN (*.JPE) DO COPY /-Y *.JPE "X:\Path\%%~nA (E-mail Size).jpe"
With this method, it did copy it to the right place and it did have the file name right, but it corrupted the file. Those JPE files are usually around 14–20 KB but after running the batch file they became around 70–100 bytes. I put the corrupted files into a text editor to see what they were and they were just gibberish, like the first part of the JPE files or something. So obviously that method isn’t going to work. Before I tried using the “FOR” command I was trying to do it with just the “COPY” command by itself with the use of wildcards, but I couldn’t get that to work either. Any ideas? Thanks!
-Adam

Never mind, I got it. I had to change this:
IF EXIST *.JPE FOR %%A IN (*.JPE) DO COPY /-Y *.JPE "X:\Path\%%~nA (E-mail Size).jpe"
to this:
IF EXIST *.JPE FOR %%A IN (*.JPE) DO COPY /-Y %%A "X:\Path\%%~nA (E-mail Size).jpe"
-Adam

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |