![]() |
![]() |
|
|
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 |
![]() |
|
|
#1 | ||
|
Guest
Posts: n/a
|
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 |
||
|
|
|
#2 | ||
|
Guest
Posts: n/a
|
"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. |
||
|
| Sponsored Links |
|
|
#3 | ||
|
Guest
Posts: n/a
|
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. > > > |
||
|
|
|
#4 | ||
|
Guest
Posts: n/a
|
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. >> >> >> |
||
|
|
|
#5 | ||
|
Guest
Posts: n/a
|
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 |
||
|
|
|
#6 | ||
|
Guest
Posts: n/a
|
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. > >> > >> > >> > > > |
||
|
|
|
#7 | ||
|
Guest
Posts: n/a
|
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. >> >> >> >> >> >> >> >> >> |
||
|
|
|
#8 | ||
|
Guest
Posts: n/a
|
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. > >> >> > >> >> > >> >> > >> > >> > >> > > > |
||
|
|
|
#9 | ||
|
Guest
Posts: n/a
|
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. >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> |
||
|
|
|
#10 | ||
|
Guest
Posts: n/a
|
"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. |
||
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|