Computing.Net > Forums > Programming > Batch file: Adding to file names

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file: Adding to file names

Reply to Message Icon

Name: AdamT
Date: January 10, 2004 at 17:32:59 Pacific
OS: Windows XP Home Edition
CPU/Ram: 1 GHz/128 MB
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: AdamT
Date: January 10, 2004 at 23:34:06 Pacific
Reply:

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


0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file: Adding to file names

Batch file to extract certain lines www.computing.net/answers/programming/batch-file-to-extract-certain-lines/17465.html

Adding .1 to file names thru Batch www.computing.net/answers/programming/adding-1-to-file-names-thru-batch/14558.html

Batch file to compute size of dir www.computing.net/answers/programming/batch-file-to-compute-size-of-dir/14387.html