Batch Rename

G

Guest

I have a large batch file that copies pdf files from one network directory to
another. It works great! Now, I was wondering if it is possible to create a
batch file that copies the files and renames them? (It would be really cool
if I could use a wildcard some how that would allow me to add the date on the
end of the file name!)

I did some playing around with the "RENAME" command, but I could not get it
to work with spaces in the file name. I need to maintain the spaces in these
file names, so is there a way to make this work? As I alluded to above, I
would like to add the date to the end of the file name. If a wild card can't
be used, I will just get it setup manually once, open the file in Excel and
use the replace command.

Thanks!

Eric
 
P

Pegasus \(MVP\)

Eric said:
I have a large batch file that copies pdf files from one network directory
to
another. It works great! Now, I was wondering if it is possible to
create a
batch file that copies the files and renames them? (It would be really
cool
if I could use a wildcard some how that would allow me to add the date on
the
end of the file name!)

I did some playing around with the "RENAME" command, but I could not get
it
to work with spaces in the file name. I need to maintain the spaces in
these
file names, so is there a way to make this work? As I alluded to above, I
would like to add the date to the end of the file name. If a wild card
can't
be used, I will just get it setup manually once, open the file in Excel
and
use the replace command.

Thanks!

Eric

It's probably possible but we can't tell you unless you supply
full details about the names ***before*** and ***after***
the rename command.
 
G

Guest

Here is an example...

Report for A & B.pdf ----> Report for A & B 1-1-07.pdf OR Report for A &
B 01012007.pdf

I would prefer the hyphenated date, but the other would be a start.

Eric
 
P

Pegasus \(MVP\)

Try this batch file:

#@echo off
#set D=%date:~4%
#set D=%D:/=-%
#dir /b *.pdf > "%temp%\dir.txt"
#for /F %%a in ('type "%temp%\dir.txt"') do echo ren "%%a" "%%~na %D%.pdf"

I marked the start of each new line with a #. You must remove
it before you can run the batch file. You must also remove the
word "echo" in the last line in order to activate it. Test it before
you activate it!
 
L

Lem

IEric said:
I have a large batch file that copies pdf files from one network directory to
another. It works great! Now, I was wondering if it is possible to create a
batch file that copies the files and renames them? (It would be really cool
if I could use a wildcard some how that would allow me to add the date on the
end of the file name!)

I did some playing around with the "RENAME" command, but I could not get it
to work with spaces in the file name. I need to maintain the spaces in these
file names, so is there a way to make this work? As I alluded to above, I
would like to add the date to the end of the file name. If a wild card can't
be used, I will just get it setup manually once, open the file in Excel and
use the replace command.

Thanks!

Eric

If you don't want to write a batch file yourself, one of my favorite
freeware applications, Irfanview, includes a batch rename facility.
Among other things, you can include a param for the system date in the
name pattern. There's even a command line syntax. It's quite a powerful
tool, so you should experiment a bit with dummy files before you turn it
loose on your entire directory of pdfs. http://www.irfanview.net/
 
G

Guest

I'm sorry... but could you give me an example of what this would look like?

For the example can you use c:\temp\temp1\Report for A & B.pdf

I'm just not sure what to all type in where.

Thanks!!
 
P

Pegasus \(MVP\)

I gave you the lines for a batch file. Do you know how
to copy & paste them into the batch file itself? If not
then maybe Lem's Irfanview suggestion might be the
best solution for you.
 
G

Guest

I certainly do know how to copy and paste! I just didn't see any reference
to any files or directories. So???????
 
P

Pegasus \(MVP\)

There is a little more to it than copying & pasting. Did you try Lem's
suggestion?
 
J

Jerry

Lem said:
If you don't want to write a batch file yourself, one of my favorite
freeware applications, Irfanview, includes a batch rename facility. Among
other things, you can include a param for the system date in the name
pattern. There's even a command line syntax. It's quite a powerful tool,
so you should experiment a bit with dummy files before you turn it loose
on your entire directory of pdfs. http://www.irfanview.net/

I love using irfanview myself but I don't see pdf's in the list of valid
file types for irfanview. I tried the batch conversion/rename function of
irfanview but can't get it to see pdf's.
 
L

Lem

Jerry said:
I love using irfanview myself but I don't see pdf's in the list of valid
file types for irfanview. I tried the batch conversion/rename function of
irfanview but can't get it to see pdf's.

On the "batch conversion" screen, under the drop-down box for "Look in"
(which specifies the directory to look in), and under the window in
which the files in that directory will be displayed, there is another
drop-down box for "Files of type". The SECOND entry in the drop-down
list is "All files (*.*)" Select that and you'll see the pdf files.

Because Irfanview is, after all, primarily a graphics file viewer, there
is no entry for pdf files per se, but if you have a directory that's
full of pdf files with few if any other types of files, this shouldn't
be a problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top