How to rename 80.000 files at once in Windows
I've 80.000 files in a folder and I need to rename all them from
filename.jpg
to
._filename.jpg
in Windows environment, I guess from dos. The reason is that I've compressed these files into a tar.gz from unix and copied into windows and for some reason the filenames have changed.
Could you tell me what's the command to do it ?
thanks
windows-7 command-line
add a comment |
I've 80.000 files in a folder and I need to rename all them from
filename.jpg
to
._filename.jpg
in Windows environment, I guess from dos. The reason is that I've compressed these files into a tar.gz from unix and copied into windows and for some reason the filenames have changed.
Could you tell me what's the command to do it ?
thanks
windows-7 command-line
add a comment |
I've 80.000 files in a folder and I need to rename all them from
filename.jpg
to
._filename.jpg
in Windows environment, I guess from dos. The reason is that I've compressed these files into a tar.gz from unix and copied into windows and for some reason the filenames have changed.
Could you tell me what's the command to do it ?
thanks
windows-7 command-line
I've 80.000 files in a folder and I need to rename all them from
filename.jpg
to
._filename.jpg
in Windows environment, I guess from dos. The reason is that I've compressed these files into a tar.gz from unix and copied into windows and for some reason the filenames have changed.
Could you tell me what's the command to do it ?
thanks
windows-7 command-line
windows-7 command-line
edited Apr 20 '11 at 11:31
Bobby
8,01133042
8,01133042
asked Apr 20 '11 at 11:19
aneuryzm
95572743
95572743
add a comment |
add a comment |
9 Answers
9
active
oldest
votes
You can use the built in rename
or ren
command:
ren *.jpg ._*.jpg
Though, as with all these things, try it on a directory containing just a few files first.
1
I like your approach, but i have 2 issues: (1) the first letters of the filenames are replaced. In other terms, the "._" is not added at the beginning but it replaces the first 2 letters. (2) "._" actually doesn't work. If I use, for instance "__" then it works. I think the dot, "." gives some issues
– aneuryzm
Apr 20 '11 at 12:02
@Patrick - I must admit I didn't have chance to fully test this this, and yes I think you're right about the dot causing problems.
– ChrisF
Apr 20 '11 at 12:05
This is incorrect and it's not because of the dots.ren
can only replace text with text of the same length. For example, if you have filesfile1.txt
andfile2.txt
,ren file*.txt blah*.txt
does what you expect (you now have filesblah1.txt
andblah2.txt
). However, if you then typeren blah*.txt myfile*.txt
the command bombs out because it renamesblah1.txt
tomyfile.txt
(notmyfile1.txt
) and then cannot renameblah2.txt
tomyfile.txt
because that file already exists.
– David Richerby
Sep 14 '14 at 11:51
add a comment |
Here's a way using PowerShell:
Navigate to your folder and run this command
Get-ChildItem *.jpg | Rename-Item -newname {"._" + $_.Name}
Extra bonus short version:
gci *.jpg | ren -newname {"._" + $_.Name}
add a comment |
I have 2 solutions:
All files are in the same folder
run the following from command prompt on that folder:
for /f "delims=¯" %i in ('dir /b /on') do ren "%i" "._%i"
complete solution when there are files in subfolders AND when you wanna to replace the "n" first characters with a string you want :D
- create a batch file with the following command
- change variable parameters to what you want
path
: put inside""
the root path of your files (e.g. "C:documents and settingsuserdesktopnew folder"
numfirstchars2replace
: put a number with the first characters to replace (in your case, 2)
str2put
: put a string to be added as a prefix of the new filename (in your case,._
)
- run it in a folder different from where the files are
@echo off
::only to tell user what this bat are doing
echo.1.initializing...
::enable that thing to allow, for example, incremental counter in a for loop :)
echo.- EnableDelayedExpansion
SETLOCAL EnableDelayedExpansion
::variables
echo.- variables
:: - place here the absolute root path of your files
set path="put here where are the root folder of your files"
set pathbak=%cd%
set numfirstchars2replace=2
set str2put=._
::go to %path% and its driveletter
echo.- entering the path you want
for /f "delims=¯" %%i in ('echo.%path%') do %%~di
cd %path%
::search all subfolders and save them to a temp file
echo.- searching for subfolders
echo.%path%>%temp%tmpvar.txt
for /f "delims=¯" %%i in ('dir /s /b /on /ad') do echo."%%i">>%temp%tmpvar.txt
::execute command for root folder and all found subfolders
echo.
echo.2.executing...
for /f "delims=¯" %%i in (%temp%tmpvar.txt) do (
cd %%i
echo.- in folder: %%i
for /f "delims=¯" %%j in ('dir /b /on /a-d') do (
set newname=%%j
set newname=!newname:~%numfirstchars2replace%,1000!
echo.- renaming from "%%j" to "%str2put%!newname!"...
ren "%%j" "%str2put%!newname!"
)
)
echo.
echo.3.exiting...
::return to %pathbak% and its driveletter
for /f "delims=¯" %%i in ('echo.%pathbak%') do %%~di
cd %pathbak%
@echo on
fully tested :) it solves your problem, including with some specs you give in @ChrisF comment. note: in "delims=¯", if "¯" is used in a filename, change "¯" with another character you know that is not used in the filenames
– kokbira
Apr 20 '11 at 14:12
voted up because of your incredibly long script to just do a loop and rename sth. :)
– wullxz
Apr 20 '11 at 22:27
well, justly, I could make a "for /f" loop with all files sorted by name and then renaming them to "._lenameX.jpg" with X as the order number, but I thought in a way to do it for other cases - if in future a similar problem appears, someone can modify some commands...
– kokbira
Apr 22 '11 at 7:38
you can use "delims=" instead of "delims=¯" (I forgot that :D). also you can use for /f intead of for /f "delims=" because it does what I want in that case...
– kokbira
Apr 25 '11 at 12:56
add a comment |
If they are all in the same folder, you could select them all with Control
+ A
and then hit F2
to rename one of them. All subsequent files will be named file(2), file(3), etc
add a comment |
Try Powershell (preinstalled in Windows 7):
Get-Childitem /path/to/your/files | foreach-object { move-item $_ $("._" + $_.name) }
(tested it in my download-dir.)
Edit: Siim K's code will append an additional ".jpg" to every "._filename.jpg".
Remove that last ".jpg" in Siim K's code and you have a short, elegant code to rename your files.
thanks, updated. Re-used code from a similar rename command which required the extension manipulation and didn't notice.
– Siim K
Apr 20 '11 at 12:05
add a comment |
Total Commander has a really nice multi-renaming tool.
add a comment |
I've always found Flash Renamer to be a good tool for renaming files in batches.
It has trial and full versions ($20) and can rename files based on meta data - very useful for renaming MP3 files which I what I use it for mostly.
add a comment |
If your looking for a user friendly way of renaming in bulk you could try the free tool Ant Renamer, there's a huge list of actions you can take and it also gives a handy preview before you do any renaming. I use it a lot when messing with my music, photo or video librarys.
add a comment |
I have used this freeware File Renamer program with great results. Many different filters and options, plus it gives you the ability to test results. A little outdated UI perhaps but works like a champ.
http://www.webxpace.com/software/freeware.shtml#FileRenamer
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f273198%2fhow-to-rename-80-000-files-at-once-in-windows%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
9 Answers
9
active
oldest
votes
9 Answers
9
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use the built in rename
or ren
command:
ren *.jpg ._*.jpg
Though, as with all these things, try it on a directory containing just a few files first.
1
I like your approach, but i have 2 issues: (1) the first letters of the filenames are replaced. In other terms, the "._" is not added at the beginning but it replaces the first 2 letters. (2) "._" actually doesn't work. If I use, for instance "__" then it works. I think the dot, "." gives some issues
– aneuryzm
Apr 20 '11 at 12:02
@Patrick - I must admit I didn't have chance to fully test this this, and yes I think you're right about the dot causing problems.
– ChrisF
Apr 20 '11 at 12:05
This is incorrect and it's not because of the dots.ren
can only replace text with text of the same length. For example, if you have filesfile1.txt
andfile2.txt
,ren file*.txt blah*.txt
does what you expect (you now have filesblah1.txt
andblah2.txt
). However, if you then typeren blah*.txt myfile*.txt
the command bombs out because it renamesblah1.txt
tomyfile.txt
(notmyfile1.txt
) and then cannot renameblah2.txt
tomyfile.txt
because that file already exists.
– David Richerby
Sep 14 '14 at 11:51
add a comment |
You can use the built in rename
or ren
command:
ren *.jpg ._*.jpg
Though, as with all these things, try it on a directory containing just a few files first.
1
I like your approach, but i have 2 issues: (1) the first letters of the filenames are replaced. In other terms, the "._" is not added at the beginning but it replaces the first 2 letters. (2) "._" actually doesn't work. If I use, for instance "__" then it works. I think the dot, "." gives some issues
– aneuryzm
Apr 20 '11 at 12:02
@Patrick - I must admit I didn't have chance to fully test this this, and yes I think you're right about the dot causing problems.
– ChrisF
Apr 20 '11 at 12:05
This is incorrect and it's not because of the dots.ren
can only replace text with text of the same length. For example, if you have filesfile1.txt
andfile2.txt
,ren file*.txt blah*.txt
does what you expect (you now have filesblah1.txt
andblah2.txt
). However, if you then typeren blah*.txt myfile*.txt
the command bombs out because it renamesblah1.txt
tomyfile.txt
(notmyfile1.txt
) and then cannot renameblah2.txt
tomyfile.txt
because that file already exists.
– David Richerby
Sep 14 '14 at 11:51
add a comment |
You can use the built in rename
or ren
command:
ren *.jpg ._*.jpg
Though, as with all these things, try it on a directory containing just a few files first.
You can use the built in rename
or ren
command:
ren *.jpg ._*.jpg
Though, as with all these things, try it on a directory containing just a few files first.
answered Apr 20 '11 at 11:36
ChrisF
38.3k1388139
38.3k1388139
1
I like your approach, but i have 2 issues: (1) the first letters of the filenames are replaced. In other terms, the "._" is not added at the beginning but it replaces the first 2 letters. (2) "._" actually doesn't work. If I use, for instance "__" then it works. I think the dot, "." gives some issues
– aneuryzm
Apr 20 '11 at 12:02
@Patrick - I must admit I didn't have chance to fully test this this, and yes I think you're right about the dot causing problems.
– ChrisF
Apr 20 '11 at 12:05
This is incorrect and it's not because of the dots.ren
can only replace text with text of the same length. For example, if you have filesfile1.txt
andfile2.txt
,ren file*.txt blah*.txt
does what you expect (you now have filesblah1.txt
andblah2.txt
). However, if you then typeren blah*.txt myfile*.txt
the command bombs out because it renamesblah1.txt
tomyfile.txt
(notmyfile1.txt
) and then cannot renameblah2.txt
tomyfile.txt
because that file already exists.
– David Richerby
Sep 14 '14 at 11:51
add a comment |
1
I like your approach, but i have 2 issues: (1) the first letters of the filenames are replaced. In other terms, the "._" is not added at the beginning but it replaces the first 2 letters. (2) "._" actually doesn't work. If I use, for instance "__" then it works. I think the dot, "." gives some issues
– aneuryzm
Apr 20 '11 at 12:02
@Patrick - I must admit I didn't have chance to fully test this this, and yes I think you're right about the dot causing problems.
– ChrisF
Apr 20 '11 at 12:05
This is incorrect and it's not because of the dots.ren
can only replace text with text of the same length. For example, if you have filesfile1.txt
andfile2.txt
,ren file*.txt blah*.txt
does what you expect (you now have filesblah1.txt
andblah2.txt
). However, if you then typeren blah*.txt myfile*.txt
the command bombs out because it renamesblah1.txt
tomyfile.txt
(notmyfile1.txt
) and then cannot renameblah2.txt
tomyfile.txt
because that file already exists.
– David Richerby
Sep 14 '14 at 11:51
1
1
I like your approach, but i have 2 issues: (1) the first letters of the filenames are replaced. In other terms, the "._" is not added at the beginning but it replaces the first 2 letters. (2) "._" actually doesn't work. If I use, for instance "__" then it works. I think the dot, "." gives some issues
– aneuryzm
Apr 20 '11 at 12:02
I like your approach, but i have 2 issues: (1) the first letters of the filenames are replaced. In other terms, the "._" is not added at the beginning but it replaces the first 2 letters. (2) "._" actually doesn't work. If I use, for instance "__" then it works. I think the dot, "." gives some issues
– aneuryzm
Apr 20 '11 at 12:02
@Patrick - I must admit I didn't have chance to fully test this this, and yes I think you're right about the dot causing problems.
– ChrisF
Apr 20 '11 at 12:05
@Patrick - I must admit I didn't have chance to fully test this this, and yes I think you're right about the dot causing problems.
– ChrisF
Apr 20 '11 at 12:05
This is incorrect and it's not because of the dots.
ren
can only replace text with text of the same length. For example, if you have files file1.txt
and file2.txt
, ren file*.txt blah*.txt
does what you expect (you now have files blah1.txt
and blah2.txt
). However, if you then type ren blah*.txt myfile*.txt
the command bombs out because it renames blah1.txt
to myfile.txt
(not myfile1.txt
) and then cannot rename blah2.txt
to myfile.txt
because that file already exists.– David Richerby
Sep 14 '14 at 11:51
This is incorrect and it's not because of the dots.
ren
can only replace text with text of the same length. For example, if you have files file1.txt
and file2.txt
, ren file*.txt blah*.txt
does what you expect (you now have files blah1.txt
and blah2.txt
). However, if you then type ren blah*.txt myfile*.txt
the command bombs out because it renames blah1.txt
to myfile.txt
(not myfile1.txt
) and then cannot rename blah2.txt
to myfile.txt
because that file already exists.– David Richerby
Sep 14 '14 at 11:51
add a comment |
Here's a way using PowerShell:
Navigate to your folder and run this command
Get-ChildItem *.jpg | Rename-Item -newname {"._" + $_.Name}
Extra bonus short version:
gci *.jpg | ren -newname {"._" + $_.Name}
add a comment |
Here's a way using PowerShell:
Navigate to your folder and run this command
Get-ChildItem *.jpg | Rename-Item -newname {"._" + $_.Name}
Extra bonus short version:
gci *.jpg | ren -newname {"._" + $_.Name}
add a comment |
Here's a way using PowerShell:
Navigate to your folder and run this command
Get-ChildItem *.jpg | Rename-Item -newname {"._" + $_.Name}
Extra bonus short version:
gci *.jpg | ren -newname {"._" + $_.Name}
Here's a way using PowerShell:
Navigate to your folder and run this command
Get-ChildItem *.jpg | Rename-Item -newname {"._" + $_.Name}
Extra bonus short version:
gci *.jpg | ren -newname {"._" + $_.Name}
edited Apr 20 '11 at 12:08
answered Apr 20 '11 at 11:35
Siim K
5,83963964
5,83963964
add a comment |
add a comment |
I have 2 solutions:
All files are in the same folder
run the following from command prompt on that folder:
for /f "delims=¯" %i in ('dir /b /on') do ren "%i" "._%i"
complete solution when there are files in subfolders AND when you wanna to replace the "n" first characters with a string you want :D
- create a batch file with the following command
- change variable parameters to what you want
path
: put inside""
the root path of your files (e.g. "C:documents and settingsuserdesktopnew folder"
numfirstchars2replace
: put a number with the first characters to replace (in your case, 2)
str2put
: put a string to be added as a prefix of the new filename (in your case,._
)
- run it in a folder different from where the files are
@echo off
::only to tell user what this bat are doing
echo.1.initializing...
::enable that thing to allow, for example, incremental counter in a for loop :)
echo.- EnableDelayedExpansion
SETLOCAL EnableDelayedExpansion
::variables
echo.- variables
:: - place here the absolute root path of your files
set path="put here where are the root folder of your files"
set pathbak=%cd%
set numfirstchars2replace=2
set str2put=._
::go to %path% and its driveletter
echo.- entering the path you want
for /f "delims=¯" %%i in ('echo.%path%') do %%~di
cd %path%
::search all subfolders and save them to a temp file
echo.- searching for subfolders
echo.%path%>%temp%tmpvar.txt
for /f "delims=¯" %%i in ('dir /s /b /on /ad') do echo."%%i">>%temp%tmpvar.txt
::execute command for root folder and all found subfolders
echo.
echo.2.executing...
for /f "delims=¯" %%i in (%temp%tmpvar.txt) do (
cd %%i
echo.- in folder: %%i
for /f "delims=¯" %%j in ('dir /b /on /a-d') do (
set newname=%%j
set newname=!newname:~%numfirstchars2replace%,1000!
echo.- renaming from "%%j" to "%str2put%!newname!"...
ren "%%j" "%str2put%!newname!"
)
)
echo.
echo.3.exiting...
::return to %pathbak% and its driveletter
for /f "delims=¯" %%i in ('echo.%pathbak%') do %%~di
cd %pathbak%
@echo on
fully tested :) it solves your problem, including with some specs you give in @ChrisF comment. note: in "delims=¯", if "¯" is used in a filename, change "¯" with another character you know that is not used in the filenames
– kokbira
Apr 20 '11 at 14:12
voted up because of your incredibly long script to just do a loop and rename sth. :)
– wullxz
Apr 20 '11 at 22:27
well, justly, I could make a "for /f" loop with all files sorted by name and then renaming them to "._lenameX.jpg" with X as the order number, but I thought in a way to do it for other cases - if in future a similar problem appears, someone can modify some commands...
– kokbira
Apr 22 '11 at 7:38
you can use "delims=" instead of "delims=¯" (I forgot that :D). also you can use for /f intead of for /f "delims=" because it does what I want in that case...
– kokbira
Apr 25 '11 at 12:56
add a comment |
I have 2 solutions:
All files are in the same folder
run the following from command prompt on that folder:
for /f "delims=¯" %i in ('dir /b /on') do ren "%i" "._%i"
complete solution when there are files in subfolders AND when you wanna to replace the "n" first characters with a string you want :D
- create a batch file with the following command
- change variable parameters to what you want
path
: put inside""
the root path of your files (e.g. "C:documents and settingsuserdesktopnew folder"
numfirstchars2replace
: put a number with the first characters to replace (in your case, 2)
str2put
: put a string to be added as a prefix of the new filename (in your case,._
)
- run it in a folder different from where the files are
@echo off
::only to tell user what this bat are doing
echo.1.initializing...
::enable that thing to allow, for example, incremental counter in a for loop :)
echo.- EnableDelayedExpansion
SETLOCAL EnableDelayedExpansion
::variables
echo.- variables
:: - place here the absolute root path of your files
set path="put here where are the root folder of your files"
set pathbak=%cd%
set numfirstchars2replace=2
set str2put=._
::go to %path% and its driveletter
echo.- entering the path you want
for /f "delims=¯" %%i in ('echo.%path%') do %%~di
cd %path%
::search all subfolders and save them to a temp file
echo.- searching for subfolders
echo.%path%>%temp%tmpvar.txt
for /f "delims=¯" %%i in ('dir /s /b /on /ad') do echo."%%i">>%temp%tmpvar.txt
::execute command for root folder and all found subfolders
echo.
echo.2.executing...
for /f "delims=¯" %%i in (%temp%tmpvar.txt) do (
cd %%i
echo.- in folder: %%i
for /f "delims=¯" %%j in ('dir /b /on /a-d') do (
set newname=%%j
set newname=!newname:~%numfirstchars2replace%,1000!
echo.- renaming from "%%j" to "%str2put%!newname!"...
ren "%%j" "%str2put%!newname!"
)
)
echo.
echo.3.exiting...
::return to %pathbak% and its driveletter
for /f "delims=¯" %%i in ('echo.%pathbak%') do %%~di
cd %pathbak%
@echo on
fully tested :) it solves your problem, including with some specs you give in @ChrisF comment. note: in "delims=¯", if "¯" is used in a filename, change "¯" with another character you know that is not used in the filenames
– kokbira
Apr 20 '11 at 14:12
voted up because of your incredibly long script to just do a loop and rename sth. :)
– wullxz
Apr 20 '11 at 22:27
well, justly, I could make a "for /f" loop with all files sorted by name and then renaming them to "._lenameX.jpg" with X as the order number, but I thought in a way to do it for other cases - if in future a similar problem appears, someone can modify some commands...
– kokbira
Apr 22 '11 at 7:38
you can use "delims=" instead of "delims=¯" (I forgot that :D). also you can use for /f intead of for /f "delims=" because it does what I want in that case...
– kokbira
Apr 25 '11 at 12:56
add a comment |
I have 2 solutions:
All files are in the same folder
run the following from command prompt on that folder:
for /f "delims=¯" %i in ('dir /b /on') do ren "%i" "._%i"
complete solution when there are files in subfolders AND when you wanna to replace the "n" first characters with a string you want :D
- create a batch file with the following command
- change variable parameters to what you want
path
: put inside""
the root path of your files (e.g. "C:documents and settingsuserdesktopnew folder"
numfirstchars2replace
: put a number with the first characters to replace (in your case, 2)
str2put
: put a string to be added as a prefix of the new filename (in your case,._
)
- run it in a folder different from where the files are
@echo off
::only to tell user what this bat are doing
echo.1.initializing...
::enable that thing to allow, for example, incremental counter in a for loop :)
echo.- EnableDelayedExpansion
SETLOCAL EnableDelayedExpansion
::variables
echo.- variables
:: - place here the absolute root path of your files
set path="put here where are the root folder of your files"
set pathbak=%cd%
set numfirstchars2replace=2
set str2put=._
::go to %path% and its driveletter
echo.- entering the path you want
for /f "delims=¯" %%i in ('echo.%path%') do %%~di
cd %path%
::search all subfolders and save them to a temp file
echo.- searching for subfolders
echo.%path%>%temp%tmpvar.txt
for /f "delims=¯" %%i in ('dir /s /b /on /ad') do echo."%%i">>%temp%tmpvar.txt
::execute command for root folder and all found subfolders
echo.
echo.2.executing...
for /f "delims=¯" %%i in (%temp%tmpvar.txt) do (
cd %%i
echo.- in folder: %%i
for /f "delims=¯" %%j in ('dir /b /on /a-d') do (
set newname=%%j
set newname=!newname:~%numfirstchars2replace%,1000!
echo.- renaming from "%%j" to "%str2put%!newname!"...
ren "%%j" "%str2put%!newname!"
)
)
echo.
echo.3.exiting...
::return to %pathbak% and its driveletter
for /f "delims=¯" %%i in ('echo.%pathbak%') do %%~di
cd %pathbak%
@echo on
I have 2 solutions:
All files are in the same folder
run the following from command prompt on that folder:
for /f "delims=¯" %i in ('dir /b /on') do ren "%i" "._%i"
complete solution when there are files in subfolders AND when you wanna to replace the "n" first characters with a string you want :D
- create a batch file with the following command
- change variable parameters to what you want
path
: put inside""
the root path of your files (e.g. "C:documents and settingsuserdesktopnew folder"
numfirstchars2replace
: put a number with the first characters to replace (in your case, 2)
str2put
: put a string to be added as a prefix of the new filename (in your case,._
)
- run it in a folder different from where the files are
@echo off
::only to tell user what this bat are doing
echo.1.initializing...
::enable that thing to allow, for example, incremental counter in a for loop :)
echo.- EnableDelayedExpansion
SETLOCAL EnableDelayedExpansion
::variables
echo.- variables
:: - place here the absolute root path of your files
set path="put here where are the root folder of your files"
set pathbak=%cd%
set numfirstchars2replace=2
set str2put=._
::go to %path% and its driveletter
echo.- entering the path you want
for /f "delims=¯" %%i in ('echo.%path%') do %%~di
cd %path%
::search all subfolders and save them to a temp file
echo.- searching for subfolders
echo.%path%>%temp%tmpvar.txt
for /f "delims=¯" %%i in ('dir /s /b /on /ad') do echo."%%i">>%temp%tmpvar.txt
::execute command for root folder and all found subfolders
echo.
echo.2.executing...
for /f "delims=¯" %%i in (%temp%tmpvar.txt) do (
cd %%i
echo.- in folder: %%i
for /f "delims=¯" %%j in ('dir /b /on /a-d') do (
set newname=%%j
set newname=!newname:~%numfirstchars2replace%,1000!
echo.- renaming from "%%j" to "%str2put%!newname!"...
ren "%%j" "%str2put%!newname!"
)
)
echo.
echo.3.exiting...
::return to %pathbak% and its driveletter
for /f "delims=¯" %%i in ('echo.%pathbak%') do %%~di
cd %pathbak%
@echo on
edited Nov 22 at 20:26
answered Apr 20 '11 at 12:41
kokbira
4,078113465
4,078113465
fully tested :) it solves your problem, including with some specs you give in @ChrisF comment. note: in "delims=¯", if "¯" is used in a filename, change "¯" with another character you know that is not used in the filenames
– kokbira
Apr 20 '11 at 14:12
voted up because of your incredibly long script to just do a loop and rename sth. :)
– wullxz
Apr 20 '11 at 22:27
well, justly, I could make a "for /f" loop with all files sorted by name and then renaming them to "._lenameX.jpg" with X as the order number, but I thought in a way to do it for other cases - if in future a similar problem appears, someone can modify some commands...
– kokbira
Apr 22 '11 at 7:38
you can use "delims=" instead of "delims=¯" (I forgot that :D). also you can use for /f intead of for /f "delims=" because it does what I want in that case...
– kokbira
Apr 25 '11 at 12:56
add a comment |
fully tested :) it solves your problem, including with some specs you give in @ChrisF comment. note: in "delims=¯", if "¯" is used in a filename, change "¯" with another character you know that is not used in the filenames
– kokbira
Apr 20 '11 at 14:12
voted up because of your incredibly long script to just do a loop and rename sth. :)
– wullxz
Apr 20 '11 at 22:27
well, justly, I could make a "for /f" loop with all files sorted by name and then renaming them to "._lenameX.jpg" with X as the order number, but I thought in a way to do it for other cases - if in future a similar problem appears, someone can modify some commands...
– kokbira
Apr 22 '11 at 7:38
you can use "delims=" instead of "delims=¯" (I forgot that :D). also you can use for /f intead of for /f "delims=" because it does what I want in that case...
– kokbira
Apr 25 '11 at 12:56
fully tested :) it solves your problem, including with some specs you give in @ChrisF comment. note: in "delims=¯", if "¯" is used in a filename, change "¯" with another character you know that is not used in the filenames
– kokbira
Apr 20 '11 at 14:12
fully tested :) it solves your problem, including with some specs you give in @ChrisF comment. note: in "delims=¯", if "¯" is used in a filename, change "¯" with another character you know that is not used in the filenames
– kokbira
Apr 20 '11 at 14:12
voted up because of your incredibly long script to just do a loop and rename sth. :)
– wullxz
Apr 20 '11 at 22:27
voted up because of your incredibly long script to just do a loop and rename sth. :)
– wullxz
Apr 20 '11 at 22:27
well, justly, I could make a "for /f" loop with all files sorted by name and then renaming them to "._lenameX.jpg" with X as the order number, but I thought in a way to do it for other cases - if in future a similar problem appears, someone can modify some commands...
– kokbira
Apr 22 '11 at 7:38
well, justly, I could make a "for /f" loop with all files sorted by name and then renaming them to "._lenameX.jpg" with X as the order number, but I thought in a way to do it for other cases - if in future a similar problem appears, someone can modify some commands...
– kokbira
Apr 22 '11 at 7:38
you can use "delims=" instead of "delims=¯" (I forgot that :D). also you can use for /f intead of for /f "delims=" because it does what I want in that case...
– kokbira
Apr 25 '11 at 12:56
you can use "delims=" instead of "delims=¯" (I forgot that :D). also you can use for /f intead of for /f "delims=" because it does what I want in that case...
– kokbira
Apr 25 '11 at 12:56
add a comment |
If they are all in the same folder, you could select them all with Control
+ A
and then hit F2
to rename one of them. All subsequent files will be named file(2), file(3), etc
add a comment |
If they are all in the same folder, you could select them all with Control
+ A
and then hit F2
to rename one of them. All subsequent files will be named file(2), file(3), etc
add a comment |
If they are all in the same folder, you could select them all with Control
+ A
and then hit F2
to rename one of them. All subsequent files will be named file(2), file(3), etc
If they are all in the same folder, you could select them all with Control
+ A
and then hit F2
to rename one of them. All subsequent files will be named file(2), file(3), etc
answered Apr 20 '11 at 11:30
bruno077
8271513
8271513
add a comment |
add a comment |
Try Powershell (preinstalled in Windows 7):
Get-Childitem /path/to/your/files | foreach-object { move-item $_ $("._" + $_.name) }
(tested it in my download-dir.)
Edit: Siim K's code will append an additional ".jpg" to every "._filename.jpg".
Remove that last ".jpg" in Siim K's code and you have a short, elegant code to rename your files.
thanks, updated. Re-used code from a similar rename command which required the extension manipulation and didn't notice.
– Siim K
Apr 20 '11 at 12:05
add a comment |
Try Powershell (preinstalled in Windows 7):
Get-Childitem /path/to/your/files | foreach-object { move-item $_ $("._" + $_.name) }
(tested it in my download-dir.)
Edit: Siim K's code will append an additional ".jpg" to every "._filename.jpg".
Remove that last ".jpg" in Siim K's code and you have a short, elegant code to rename your files.
thanks, updated. Re-used code from a similar rename command which required the extension manipulation and didn't notice.
– Siim K
Apr 20 '11 at 12:05
add a comment |
Try Powershell (preinstalled in Windows 7):
Get-Childitem /path/to/your/files | foreach-object { move-item $_ $("._" + $_.name) }
(tested it in my download-dir.)
Edit: Siim K's code will append an additional ".jpg" to every "._filename.jpg".
Remove that last ".jpg" in Siim K's code and you have a short, elegant code to rename your files.
Try Powershell (preinstalled in Windows 7):
Get-Childitem /path/to/your/files | foreach-object { move-item $_ $("._" + $_.name) }
(tested it in my download-dir.)
Edit: Siim K's code will append an additional ".jpg" to every "._filename.jpg".
Remove that last ".jpg" in Siim K's code and you have a short, elegant code to rename your files.
edited Apr 20 '11 at 11:42
answered Apr 20 '11 at 11:31
wullxz
2,06141633
2,06141633
thanks, updated. Re-used code from a similar rename command which required the extension manipulation and didn't notice.
– Siim K
Apr 20 '11 at 12:05
add a comment |
thanks, updated. Re-used code from a similar rename command which required the extension manipulation and didn't notice.
– Siim K
Apr 20 '11 at 12:05
thanks, updated. Re-used code from a similar rename command which required the extension manipulation and didn't notice.
– Siim K
Apr 20 '11 at 12:05
thanks, updated. Re-used code from a similar rename command which required the extension manipulation and didn't notice.
– Siim K
Apr 20 '11 at 12:05
add a comment |
Total Commander has a really nice multi-renaming tool.
add a comment |
Total Commander has a really nice multi-renaming tool.
add a comment |
Total Commander has a really nice multi-renaming tool.
Total Commander has a really nice multi-renaming tool.
edited Apr 20 '11 at 13:14
3498DB
15.7k114762
15.7k114762
answered Apr 20 '11 at 11:32
György Andrasek
1955
1955
add a comment |
add a comment |
I've always found Flash Renamer to be a good tool for renaming files in batches.
It has trial and full versions ($20) and can rename files based on meta data - very useful for renaming MP3 files which I what I use it for mostly.
add a comment |
I've always found Flash Renamer to be a good tool for renaming files in batches.
It has trial and full versions ($20) and can rename files based on meta data - very useful for renaming MP3 files which I what I use it for mostly.
add a comment |
I've always found Flash Renamer to be a good tool for renaming files in batches.
It has trial and full versions ($20) and can rename files based on meta data - very useful for renaming MP3 files which I what I use it for mostly.
I've always found Flash Renamer to be a good tool for renaming files in batches.
It has trial and full versions ($20) and can rename files based on meta data - very useful for renaming MP3 files which I what I use it for mostly.
answered Apr 20 '11 at 18:23
ajcw
18017
18017
add a comment |
add a comment |
If your looking for a user friendly way of renaming in bulk you could try the free tool Ant Renamer, there's a huge list of actions you can take and it also gives a handy preview before you do any renaming. I use it a lot when messing with my music, photo or video librarys.
add a comment |
If your looking for a user friendly way of renaming in bulk you could try the free tool Ant Renamer, there's a huge list of actions you can take and it also gives a handy preview before you do any renaming. I use it a lot when messing with my music, photo or video librarys.
add a comment |
If your looking for a user friendly way of renaming in bulk you could try the free tool Ant Renamer, there's a huge list of actions you can take and it also gives a handy preview before you do any renaming. I use it a lot when messing with my music, photo or video librarys.
If your looking for a user friendly way of renaming in bulk you could try the free tool Ant Renamer, there's a huge list of actions you can take and it also gives a handy preview before you do any renaming. I use it a lot when messing with my music, photo or video librarys.
answered Apr 27 '11 at 17:41
Chris
1
1
add a comment |
add a comment |
I have used this freeware File Renamer program with great results. Many different filters and options, plus it gives you the ability to test results. A little outdated UI perhaps but works like a champ.
http://www.webxpace.com/software/freeware.shtml#FileRenamer
add a comment |
I have used this freeware File Renamer program with great results. Many different filters and options, plus it gives you the ability to test results. A little outdated UI perhaps but works like a champ.
http://www.webxpace.com/software/freeware.shtml#FileRenamer
add a comment |
I have used this freeware File Renamer program with great results. Many different filters and options, plus it gives you the ability to test results. A little outdated UI perhaps but works like a champ.
http://www.webxpace.com/software/freeware.shtml#FileRenamer
I have used this freeware File Renamer program with great results. Many different filters and options, plus it gives you the ability to test results. A little outdated UI perhaps but works like a champ.
http://www.webxpace.com/software/freeware.shtml#FileRenamer
answered Apr 29 '11 at 5:43
Mark A
287412
287412
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f273198%2fhow-to-rename-80-000-files-at-once-in-windows%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