Thread: Batch Rename
View Single Post
  #4 (permalink)  
Old 10-03-2007, 02:00 PM
Pegasus \(MVP\)
Newsgroup Contributor
 
Posts: n/a
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.
>>
>>
>>



Reply With Quote

 
Old 10-03-2007, 02:00 PM