In Windows, add a prefix to multiple PDF files
up vote
2
down vote
favorite
I have a folder with 100 invoices & they all need to carry the prefix "INVOICE_" in front. I tried to run a command but it doesn't seem to be working.
I've tried ren * INVOICE_*.PDF but it doesn't work. Can someone help me figure this out?
windows cmd.exe
New contributor
Lia is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
2
down vote
favorite
I have a folder with 100 invoices & they all need to carry the prefix "INVOICE_" in front. I tried to run a command but it doesn't seem to be working.
I've tried ren * INVOICE_*.PDF but it doesn't work. Can someone help me figure this out?
windows cmd.exe
New contributor
Lia is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
softwarerecs.stackexchange.com is the preferred place to ask about apps which you could add to do this, should you be using Windows which does not know how to do that.
– K7AAY
Nov 15 at 0:36
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have a folder with 100 invoices & they all need to carry the prefix "INVOICE_" in front. I tried to run a command but it doesn't seem to be working.
I've tried ren * INVOICE_*.PDF but it doesn't work. Can someone help me figure this out?
windows cmd.exe
New contributor
Lia is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have a folder with 100 invoices & they all need to carry the prefix "INVOICE_" in front. I tried to run a command but it doesn't seem to be working.
I've tried ren * INVOICE_*.PDF but it doesn't work. Can someone help me figure this out?
windows cmd.exe
windows cmd.exe
New contributor
Lia is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Lia is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Nov 15 at 0:38
K7AAY
3,06621437
3,06621437
New contributor
Lia is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Nov 15 at 0:28
Lia
111
111
New contributor
Lia is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Lia is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Lia is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
softwarerecs.stackexchange.com is the preferred place to ask about apps which you could add to do this, should you be using Windows which does not know how to do that.
– K7AAY
Nov 15 at 0:36
add a comment |
softwarerecs.stackexchange.com is the preferred place to ask about apps which you could add to do this, should you be using Windows which does not know how to do that.
– K7AAY
Nov 15 at 0:36
softwarerecs.stackexchange.com is the preferred place to ask about apps which you could add to do this, should you be using Windows which does not know how to do that.
– K7AAY
Nov 15 at 0:36
softwarerecs.stackexchange.com is the preferred place to ask about apps which you could add to do this, should you be using Windows which does not know how to do that.
– K7AAY
Nov 15 at 0:36
add a comment |
4 Answers
4
active
oldest
votes
up vote
2
down vote
A quick and dirty batch file which will do what you want.
@echo off
::Create a temporary filename.
set _tmpfile=%random%
::Store the prefix you want to use in the rename in a variable
set _prefix=INVOICE_
::List of files to be renamed are held in the _tmpfile
::so be sure that you are in the correct folder/directory.
dir *.pdf /b>%_tmpfile%
::Now, loop through the _tmpfile and rename each file using the _prefix variable
:: Remove the ECHO below in order for this to work.
for /f %%x in (%_tmpfile%) do ECHO ren %%x %_prefix%%%x
::Delete the _tmpfile
if exist %_tmpfile% del %_tmpfile%
Update: the batch file, as is, won't rename the files. It would just show you the command it would run if you remove the "ECHO" string from the "for /f in %%x" line. Then the batch file will rename the files.
Hope this helps!
You might want to explain the bit about doing a dry run and then deleting theECHO. (2) Why don’t you just dofor %%x in (*.pdf) doand skip the tmpfile?
– Scott
Nov 15 at 20:56
@scott: for #1, I thought the comments in the batch file would be enough. I'll update the answer. For #2, during my testing, the batch would add the prefix twice to the first file. Figured safest thing was to redirect to temp file, then loop that.
– JSanchez
Nov 16 at 0:44
add a comment |
up vote
1
down vote
The ren command works differently than you expect; click on its link to learn more about it. A third party file renaming utility will make this much easier. There are a number of Open Source free programs which are available, such as
https://sourceforge.net/projects/renameit/
http://file-folder-ren.sourceforge.net/
https://sourceforge.net/projects/mfrv02/
https://sourceforge.net/projects/multifilerename/
https://sourceforge.net/projects/freefilerenamer/
https://sourceforge.net/projects/personalrenamer/
http://regexrenamer.sourceforge.net/
http://rename.sourceforge.net/
among others.
Can't make a recommendation of a specific app here, but https://softwarerecs.stackexchange.com is the preferred place to ask about apps.
add a comment |
up vote
1
down vote
You question title says “in Windows”,
so I’m going to ignore the cmd.exe tag
and give you a PowerShell solution.
Go into PowerShell
(type powershell at your cmd prompt, or run it from the menu)
and type
dir *.pdf | rename-item -newname {$_.name -replace "^","INVOICE_"}
Seems pretty self-explanatory: take the name of each PDF file
and rename it to a new name that’s formed
by replacing the beginning of the old name
(denoted by the regular expression ^) with “INVOICE_”.
Copied almost verbatim
from How to Batch Rename Multiple Files in Windows at How-To Geek.
add a comment |
up vote
-1
down vote
Try this command
ren *.pdf INVOICE_*.pdf
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
A quick and dirty batch file which will do what you want.
@echo off
::Create a temporary filename.
set _tmpfile=%random%
::Store the prefix you want to use in the rename in a variable
set _prefix=INVOICE_
::List of files to be renamed are held in the _tmpfile
::so be sure that you are in the correct folder/directory.
dir *.pdf /b>%_tmpfile%
::Now, loop through the _tmpfile and rename each file using the _prefix variable
:: Remove the ECHO below in order for this to work.
for /f %%x in (%_tmpfile%) do ECHO ren %%x %_prefix%%%x
::Delete the _tmpfile
if exist %_tmpfile% del %_tmpfile%
Update: the batch file, as is, won't rename the files. It would just show you the command it would run if you remove the "ECHO" string from the "for /f in %%x" line. Then the batch file will rename the files.
Hope this helps!
You might want to explain the bit about doing a dry run and then deleting theECHO. (2) Why don’t you just dofor %%x in (*.pdf) doand skip the tmpfile?
– Scott
Nov 15 at 20:56
@scott: for #1, I thought the comments in the batch file would be enough. I'll update the answer. For #2, during my testing, the batch would add the prefix twice to the first file. Figured safest thing was to redirect to temp file, then loop that.
– JSanchez
Nov 16 at 0:44
add a comment |
up vote
2
down vote
A quick and dirty batch file which will do what you want.
@echo off
::Create a temporary filename.
set _tmpfile=%random%
::Store the prefix you want to use in the rename in a variable
set _prefix=INVOICE_
::List of files to be renamed are held in the _tmpfile
::so be sure that you are in the correct folder/directory.
dir *.pdf /b>%_tmpfile%
::Now, loop through the _tmpfile and rename each file using the _prefix variable
:: Remove the ECHO below in order for this to work.
for /f %%x in (%_tmpfile%) do ECHO ren %%x %_prefix%%%x
::Delete the _tmpfile
if exist %_tmpfile% del %_tmpfile%
Update: the batch file, as is, won't rename the files. It would just show you the command it would run if you remove the "ECHO" string from the "for /f in %%x" line. Then the batch file will rename the files.
Hope this helps!
You might want to explain the bit about doing a dry run and then deleting theECHO. (2) Why don’t you just dofor %%x in (*.pdf) doand skip the tmpfile?
– Scott
Nov 15 at 20:56
@scott: for #1, I thought the comments in the batch file would be enough. I'll update the answer. For #2, during my testing, the batch would add the prefix twice to the first file. Figured safest thing was to redirect to temp file, then loop that.
– JSanchez
Nov 16 at 0:44
add a comment |
up vote
2
down vote
up vote
2
down vote
A quick and dirty batch file which will do what you want.
@echo off
::Create a temporary filename.
set _tmpfile=%random%
::Store the prefix you want to use in the rename in a variable
set _prefix=INVOICE_
::List of files to be renamed are held in the _tmpfile
::so be sure that you are in the correct folder/directory.
dir *.pdf /b>%_tmpfile%
::Now, loop through the _tmpfile and rename each file using the _prefix variable
:: Remove the ECHO below in order for this to work.
for /f %%x in (%_tmpfile%) do ECHO ren %%x %_prefix%%%x
::Delete the _tmpfile
if exist %_tmpfile% del %_tmpfile%
Update: the batch file, as is, won't rename the files. It would just show you the command it would run if you remove the "ECHO" string from the "for /f in %%x" line. Then the batch file will rename the files.
Hope this helps!
A quick and dirty batch file which will do what you want.
@echo off
::Create a temporary filename.
set _tmpfile=%random%
::Store the prefix you want to use in the rename in a variable
set _prefix=INVOICE_
::List of files to be renamed are held in the _tmpfile
::so be sure that you are in the correct folder/directory.
dir *.pdf /b>%_tmpfile%
::Now, loop through the _tmpfile and rename each file using the _prefix variable
:: Remove the ECHO below in order for this to work.
for /f %%x in (%_tmpfile%) do ECHO ren %%x %_prefix%%%x
::Delete the _tmpfile
if exist %_tmpfile% del %_tmpfile%
Update: the batch file, as is, won't rename the files. It would just show you the command it would run if you remove the "ECHO" string from the "for /f in %%x" line. Then the batch file will rename the files.
Hope this helps!
edited Nov 16 at 0:48
answered Nov 15 at 1:20
JSanchez
1,51289
1,51289
You might want to explain the bit about doing a dry run and then deleting theECHO. (2) Why don’t you just dofor %%x in (*.pdf) doand skip the tmpfile?
– Scott
Nov 15 at 20:56
@scott: for #1, I thought the comments in the batch file would be enough. I'll update the answer. For #2, during my testing, the batch would add the prefix twice to the first file. Figured safest thing was to redirect to temp file, then loop that.
– JSanchez
Nov 16 at 0:44
add a comment |
You might want to explain the bit about doing a dry run and then deleting theECHO. (2) Why don’t you just dofor %%x in (*.pdf) doand skip the tmpfile?
– Scott
Nov 15 at 20:56
@scott: for #1, I thought the comments in the batch file would be enough. I'll update the answer. For #2, during my testing, the batch would add the prefix twice to the first file. Figured safest thing was to redirect to temp file, then loop that.
– JSanchez
Nov 16 at 0:44
You might want to explain the bit about doing a dry run and then deleting the
ECHO. (2) Why don’t you just do for %%x in (*.pdf) do and skip the tmpfile?– Scott
Nov 15 at 20:56
You might want to explain the bit about doing a dry run and then deleting the
ECHO. (2) Why don’t you just do for %%x in (*.pdf) do and skip the tmpfile?– Scott
Nov 15 at 20:56
@scott: for #1, I thought the comments in the batch file would be enough. I'll update the answer. For #2, during my testing, the batch would add the prefix twice to the first file. Figured safest thing was to redirect to temp file, then loop that.
– JSanchez
Nov 16 at 0:44
@scott: for #1, I thought the comments in the batch file would be enough. I'll update the answer. For #2, during my testing, the batch would add the prefix twice to the first file. Figured safest thing was to redirect to temp file, then loop that.
– JSanchez
Nov 16 at 0:44
add a comment |
up vote
1
down vote
The ren command works differently than you expect; click on its link to learn more about it. A third party file renaming utility will make this much easier. There are a number of Open Source free programs which are available, such as
https://sourceforge.net/projects/renameit/
http://file-folder-ren.sourceforge.net/
https://sourceforge.net/projects/mfrv02/
https://sourceforge.net/projects/multifilerename/
https://sourceforge.net/projects/freefilerenamer/
https://sourceforge.net/projects/personalrenamer/
http://regexrenamer.sourceforge.net/
http://rename.sourceforge.net/
among others.
Can't make a recommendation of a specific app here, but https://softwarerecs.stackexchange.com is the preferred place to ask about apps.
add a comment |
up vote
1
down vote
The ren command works differently than you expect; click on its link to learn more about it. A third party file renaming utility will make this much easier. There are a number of Open Source free programs which are available, such as
https://sourceforge.net/projects/renameit/
http://file-folder-ren.sourceforge.net/
https://sourceforge.net/projects/mfrv02/
https://sourceforge.net/projects/multifilerename/
https://sourceforge.net/projects/freefilerenamer/
https://sourceforge.net/projects/personalrenamer/
http://regexrenamer.sourceforge.net/
http://rename.sourceforge.net/
among others.
Can't make a recommendation of a specific app here, but https://softwarerecs.stackexchange.com is the preferred place to ask about apps.
add a comment |
up vote
1
down vote
up vote
1
down vote
The ren command works differently than you expect; click on its link to learn more about it. A third party file renaming utility will make this much easier. There are a number of Open Source free programs which are available, such as
https://sourceforge.net/projects/renameit/
http://file-folder-ren.sourceforge.net/
https://sourceforge.net/projects/mfrv02/
https://sourceforge.net/projects/multifilerename/
https://sourceforge.net/projects/freefilerenamer/
https://sourceforge.net/projects/personalrenamer/
http://regexrenamer.sourceforge.net/
http://rename.sourceforge.net/
among others.
Can't make a recommendation of a specific app here, but https://softwarerecs.stackexchange.com is the preferred place to ask about apps.
The ren command works differently than you expect; click on its link to learn more about it. A third party file renaming utility will make this much easier. There are a number of Open Source free programs which are available, such as
https://sourceforge.net/projects/renameit/
http://file-folder-ren.sourceforge.net/
https://sourceforge.net/projects/mfrv02/
https://sourceforge.net/projects/multifilerename/
https://sourceforge.net/projects/freefilerenamer/
https://sourceforge.net/projects/personalrenamer/
http://regexrenamer.sourceforge.net/
http://rename.sourceforge.net/
among others.
Can't make a recommendation of a specific app here, but https://softwarerecs.stackexchange.com is the preferred place to ask about apps.
answered Nov 15 at 0:47
K7AAY
3,06621437
3,06621437
add a comment |
add a comment |
up vote
1
down vote
You question title says “in Windows”,
so I’m going to ignore the cmd.exe tag
and give you a PowerShell solution.
Go into PowerShell
(type powershell at your cmd prompt, or run it from the menu)
and type
dir *.pdf | rename-item -newname {$_.name -replace "^","INVOICE_"}
Seems pretty self-explanatory: take the name of each PDF file
and rename it to a new name that’s formed
by replacing the beginning of the old name
(denoted by the regular expression ^) with “INVOICE_”.
Copied almost verbatim
from How to Batch Rename Multiple Files in Windows at How-To Geek.
add a comment |
up vote
1
down vote
You question title says “in Windows”,
so I’m going to ignore the cmd.exe tag
and give you a PowerShell solution.
Go into PowerShell
(type powershell at your cmd prompt, or run it from the menu)
and type
dir *.pdf | rename-item -newname {$_.name -replace "^","INVOICE_"}
Seems pretty self-explanatory: take the name of each PDF file
and rename it to a new name that’s formed
by replacing the beginning of the old name
(denoted by the regular expression ^) with “INVOICE_”.
Copied almost verbatim
from How to Batch Rename Multiple Files in Windows at How-To Geek.
add a comment |
up vote
1
down vote
up vote
1
down vote
You question title says “in Windows”,
so I’m going to ignore the cmd.exe tag
and give you a PowerShell solution.
Go into PowerShell
(type powershell at your cmd prompt, or run it from the menu)
and type
dir *.pdf | rename-item -newname {$_.name -replace "^","INVOICE_"}
Seems pretty self-explanatory: take the name of each PDF file
and rename it to a new name that’s formed
by replacing the beginning of the old name
(denoted by the regular expression ^) with “INVOICE_”.
Copied almost verbatim
from How to Batch Rename Multiple Files in Windows at How-To Geek.
You question title says “in Windows”,
so I’m going to ignore the cmd.exe tag
and give you a PowerShell solution.
Go into PowerShell
(type powershell at your cmd prompt, or run it from the menu)
and type
dir *.pdf | rename-item -newname {$_.name -replace "^","INVOICE_"}
Seems pretty self-explanatory: take the name of each PDF file
and rename it to a new name that’s formed
by replacing the beginning of the old name
(denoted by the regular expression ^) with “INVOICE_”.
Copied almost verbatim
from How to Batch Rename Multiple Files in Windows at How-To Geek.
answered Nov 15 at 7:04
Scott
15.4k113789
15.4k113789
add a comment |
add a comment |
up vote
-1
down vote
Try this command
ren *.pdf INVOICE_*.pdf
add a comment |
up vote
-1
down vote
Try this command
ren *.pdf INVOICE_*.pdf
add a comment |
up vote
-1
down vote
up vote
-1
down vote
Try this command
ren *.pdf INVOICE_*.pdf
Try this command
ren *.pdf INVOICE_*.pdf
answered Nov 15 at 0:47
Keltari
48.8k17112161
48.8k17112161
add a comment |
add a comment |
Lia is a new contributor. Be nice, and check out our Code of Conduct.
Lia is a new contributor. Be nice, and check out our Code of Conduct.
Lia is a new contributor. Be nice, and check out our Code of Conduct.
Lia is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1375506%2fin-windows-add-a-prefix-to-multiple-pdf-files%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
softwarerecs.stackexchange.com is the preferred place to ask about apps which you could add to do this, should you be using Windows which does not know how to do that.
– K7AAY
Nov 15 at 0:36