MS OS - Microsoft Forum to Usenet Gateway Header Right
Navbar Left Navbar Right


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



Reply
Old 10-03-2007, 04:19 PM   #1
Eric
Guest
 
Posts: n/a
Default Batch Rename

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

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-03-2007, 04:22 PM   #2
Pegasus \(MVP\)
Guest
 
Posts: n/a
Default Re: Batch Rename


"Eric" <Eric@discussions.microsoft.com> wrote in message
news:1B007E04-5DF6-438D-A5F3-3FFEB7182D85@microsoft.com...
>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.


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 10-03-2007, 04:36 PM   #3
Eric
Guest
 
Posts: n/a
Default Re: Batch Rename

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

"Pegasus (MVP)" wrote:

>
> "Eric" <Eric@discussions.microsoft.com> wrote in message
> news:1B007E04-5DF6-438D-A5F3-3FFEB7182D85@microsoft.com...
> >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.
>
>
>

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-03-2007, 04:51 PM   #4
Pegasus \(MVP\)
Guest
 
Posts: n/a
Default Re: Batch Rename

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!


"Eric" <Eric@discussions.microsoft.com> wrote in message
news:38543FB2-4734-40ED-8742-29E7097B2398@microsoft.com...
> 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
>
> "Pegasus (MVP)" wrote:
>
>>
>> "Eric" <Eric@discussions.microsoft.com> wrote in message
>> news:1B007E04-5DF6-438D-A5F3-3FFEB7182D85@microsoft.com...
>> >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.
>>
>>
>>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-03-2007, 04:59 PM   #5
Lem
Guest
 
Posts: n/a
Default Re: Batch Rename

IEric wrote:
> 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/


--
Lem -- MS-MVP - Networking

To the moon and back with 64 Kbits of RAM and 512 Kbits of ROM.
http://en.wikipedia.org/wiki/Apollo_Guidance_Computer
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-03-2007, 05:06 PM   #6
Eric
Guest
 
Posts: n/a
Default Re: Batch Rename

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!!

"Pegasus (MVP)" wrote:

> 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!
>
>
> "Eric" <Eric@discussions.microsoft.com> wrote in message
> news:38543FB2-4734-40ED-8742-29E7097B2398@microsoft.com...
> > 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
> >
> > "Pegasus (MVP)" wrote:
> >
> >>
> >> "Eric" <Eric@discussions.microsoft.com> wrote in message
> >> news:1B007E04-5DF6-438D-A5F3-3FFEB7182D85@microsoft.com...
> >> >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.
> >>
> >>
> >>

>
>
>

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-03-2007, 05:13 PM   #7
Pegasus \(MVP\)
Guest
 
Posts: n/a
Default Re: Batch Rename

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.


"Eric" <Eric@discussions.microsoft.com> wrote in message
news:CD52DCF4-3127-4288-8B26-73727D6E990A@microsoft.com...
> 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!!
>
> "Pegasus (MVP)" wrote:
>
>> 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!
>>
>>
>> "Eric" <Eric@discussions.microsoft.com> wrote in message
>> news:38543FB2-4734-40ED-8742-29E7097B2398@microsoft.com...
>> > 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
>> >
>> > "Pegasus (MVP)" wrote:
>> >
>> >>
>> >> "Eric" <Eric@discussions.microsoft.com> wrote in message
>> >> news:1B007E04-5DF6-438D-A5F3-3FFEB7182D85@microsoft.com...
>> >> >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.
>> >>
>> >>
>> >>

>>
>>
>>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-03-2007, 05:30 PM   #8
Eric
Guest
 
Posts: n/a
Default Re: Batch Rename

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

"Pegasus (MVP)" wrote:

> 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.
>
>
> "Eric" <Eric@discussions.microsoft.com> wrote in message
> news:CD52DCF4-3127-4288-8B26-73727D6E990A@microsoft.com...
> > 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!!
> >
> > "Pegasus (MVP)" wrote:
> >
> >> 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!
> >>
> >>
> >> "Eric" <Eric@discussions.microsoft.com> wrote in message
> >> news:38543FB2-4734-40ED-8742-29E7097B2398@microsoft.com...
> >> > 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
> >> >
> >> > "Pegasus (MVP)" wrote:
> >> >
> >> >>
> >> >> "Eric" <Eric@discussions.microsoft.com> wrote in message
> >> >> news:1B007E04-5DF6-438D-A5F3-3FFEB7182D85@microsoft.com...
> >> >> >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.
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>

>
>
>

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-03-2007, 05:58 PM   #9
Pegasus \(MVP\)
Guest
 
Posts: n/a
Default Re: Batch Rename

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


"Eric" <Eric@discussions.microsoft.com> wrote in message
news:9B76C8DB-6CFD-4C5E-BCB6-331EA3E26657@microsoft.com...
>I certainly do know how to copy and paste! I just didn't see any reference
> to any files or directories. So???????
>
> "Pegasus (MVP)" wrote:
>
>> 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.
>>
>>
>> "Eric" <Eric@discussions.microsoft.com> wrote in message
>> news:CD52DCF4-3127-4288-8B26-73727D6E990A@microsoft.com...
>> > 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!!
>> >
>> > "Pegasus (MVP)" wrote:
>> >
>> >> 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!
>> >>
>> >>
>> >> "Eric" <Eric@discussions.microsoft.com> wrote in message
>> >> news:38543FB2-4734-40ED-8742-29E7097B2398@microsoft.com...
>> >> > 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
>> >> >
>> >> > "Pegasus (MVP)" wrote:
>> >> >
>> >> >>
>> >> >> "Eric" <Eric@discussions.microsoft.com> wrote in message
>> >> >> news:1B007E04-5DF6-438D-A5F3-3FFEB7182D85@microsoft.com...
>> >> >> >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.
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>

>>
>>
>>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-03-2007, 11:25 PM   #10
Jerry
Guest
 
Posts: n/a
Default Re: Batch Rename

"Lem" <lemp40@hotmail.com> wrote in message
news:ODoFbBgBIHA.5280@TK2MSFTNGP05.phx.gbl...
> IEric wrote:
>> 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/
>
>
> --
> Lem -- MS-MVP - Networking


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.


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


All times are GMT -5. The time now is 08:23 AM.


Powered by vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Skin designed by CompletevB
Copyright © 2005-2008 Robert Schwarz, Sr. - All rights reserved - MS OS is an independent web site and is not affiliated with Microsoft Corporation.