How to rename multiple files in multiple folders with one command
We want to rename our *.html
files to *.php
but (sadly enough) have not enough knowledge to do it with a cmd prompt command and/or batch file.
The problem is that each file is in separate folder –
and I am talking about 750+ different folder names.
Using wildcards for the files I know is the *
but using also a wildcard for folders is unknown to me.
We probably need to use the FOR
command (in Command Prompt),
but there I am stuck.
Folder structure we use is:
parent-folder/child-folder/grandchild-folder/file.html
for example:
games/A/game_name/file.html
games/B/game_name/file.html
games/C/game_name/file.html
and so on.
The parent folder is the same for all files; the child & grandchild folders are different for most files.
After renaming these files to *.php
I assume the following in the .htaccess
will make a permanent redirect.
RedirectMatch 301 (.*).html$ http://oursite.com$1.php
windows php html powershell batch-rename
add a comment |
We want to rename our *.html
files to *.php
but (sadly enough) have not enough knowledge to do it with a cmd prompt command and/or batch file.
The problem is that each file is in separate folder –
and I am talking about 750+ different folder names.
Using wildcards for the files I know is the *
but using also a wildcard for folders is unknown to me.
We probably need to use the FOR
command (in Command Prompt),
but there I am stuck.
Folder structure we use is:
parent-folder/child-folder/grandchild-folder/file.html
for example:
games/A/game_name/file.html
games/B/game_name/file.html
games/C/game_name/file.html
and so on.
The parent folder is the same for all files; the child & grandchild folders are different for most files.
After renaming these files to *.php
I assume the following in the .htaccess
will make a permanent redirect.
RedirectMatch 301 (.*).html$ http://oursite.com$1.php
windows php html powershell batch-rename
add a comment |
We want to rename our *.html
files to *.php
but (sadly enough) have not enough knowledge to do it with a cmd prompt command and/or batch file.
The problem is that each file is in separate folder –
and I am talking about 750+ different folder names.
Using wildcards for the files I know is the *
but using also a wildcard for folders is unknown to me.
We probably need to use the FOR
command (in Command Prompt),
but there I am stuck.
Folder structure we use is:
parent-folder/child-folder/grandchild-folder/file.html
for example:
games/A/game_name/file.html
games/B/game_name/file.html
games/C/game_name/file.html
and so on.
The parent folder is the same for all files; the child & grandchild folders are different for most files.
After renaming these files to *.php
I assume the following in the .htaccess
will make a permanent redirect.
RedirectMatch 301 (.*).html$ http://oursite.com$1.php
windows php html powershell batch-rename
We want to rename our *.html
files to *.php
but (sadly enough) have not enough knowledge to do it with a cmd prompt command and/or batch file.
The problem is that each file is in separate folder –
and I am talking about 750+ different folder names.
Using wildcards for the files I know is the *
but using also a wildcard for folders is unknown to me.
We probably need to use the FOR
command (in Command Prompt),
but there I am stuck.
Folder structure we use is:
parent-folder/child-folder/grandchild-folder/file.html
for example:
games/A/game_name/file.html
games/B/game_name/file.html
games/C/game_name/file.html
and so on.
The parent folder is the same for all files; the child & grandchild folders are different for most files.
After renaming these files to *.php
I assume the following in the .htaccess
will make a permanent redirect.
RedirectMatch 301 (.*).html$ http://oursite.com$1.php
windows php html powershell batch-rename
windows php html powershell batch-rename
edited Jan 31 '16 at 1:35
G-Man
5,627112358
5,627112358
asked Mar 21 '12 at 11:00
CharlesCharles
2081310
2081310
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
get-childItem -recurse | Where {$_.extension -eq ".html"} | rename-item -newname { $_.name -replace ".html",".php" }
This will work in PowerShell. If you have Windows 7 or Vista, you should have it installed by default. If you are on XP you can download it here.
Soandos, Chapeau !!!!!!!!!!!! Many thanx from this side, works like a charm.
– Charles
Mar 21 '12 at 11:31
@Charles, if this solved your problem, please click the check mark, so that everyone else that sees it will know it worked. Welcome to SuperUser.
– soandos
Mar 21 '12 at 11:33
add a comment |
In command line:
for /f "delims=*" %a in ('dir *.html /b /s') do ren "%a" *.php
Note: You can replace *.html
for other wildcard, e.g. d:www*.html
.
Note 2: If using the command within a batch file, replace %a
with %%a
(don't ask me why)
Why do you say"delims=*"
?"delims="
should be good enough (i.e., why do you specify a delimiter of*
?
– G-Man
Jan 31 '16 at 1:34
add a comment |
Flexible Renamer is an excellent little program that will handle several different types of renaming searches/replaces. It accepts regular expressions, and has common patterns predefined. Additionally, it allows you to include items in subfolders, or operate on folders themselves. It also gives you a preview of all changes that will be made. I have used it for years, and highly recommend it.
http://download.cnet.com/Flexible-Renamer/3000-2248_4-28799.html
This made my day ! Thanks so much !
– Shaig Khaligli
Dec 8 '18 at 12:32
add a comment |
Using forfiles, we can write a script, to rename files recursively in all subfolders.
forfiles /S /M *.html /C "cmd /c rename @file @fname.php"
Source: Batch script for renaming files in bulk
add a comment |
TotalCommander: Search - Send to Panel - Multi-Rename Tool
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%2f403183%2fhow-to-rename-multiple-files-in-multiple-folders-with-one-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
get-childItem -recurse | Where {$_.extension -eq ".html"} | rename-item -newname { $_.name -replace ".html",".php" }
This will work in PowerShell. If you have Windows 7 or Vista, you should have it installed by default. If you are on XP you can download it here.
Soandos, Chapeau !!!!!!!!!!!! Many thanx from this side, works like a charm.
– Charles
Mar 21 '12 at 11:31
@Charles, if this solved your problem, please click the check mark, so that everyone else that sees it will know it worked. Welcome to SuperUser.
– soandos
Mar 21 '12 at 11:33
add a comment |
get-childItem -recurse | Where {$_.extension -eq ".html"} | rename-item -newname { $_.name -replace ".html",".php" }
This will work in PowerShell. If you have Windows 7 or Vista, you should have it installed by default. If you are on XP you can download it here.
Soandos, Chapeau !!!!!!!!!!!! Many thanx from this side, works like a charm.
– Charles
Mar 21 '12 at 11:31
@Charles, if this solved your problem, please click the check mark, so that everyone else that sees it will know it worked. Welcome to SuperUser.
– soandos
Mar 21 '12 at 11:33
add a comment |
get-childItem -recurse | Where {$_.extension -eq ".html"} | rename-item -newname { $_.name -replace ".html",".php" }
This will work in PowerShell. If you have Windows 7 or Vista, you should have it installed by default. If you are on XP you can download it here.
get-childItem -recurse | Where {$_.extension -eq ".html"} | rename-item -newname { $_.name -replace ".html",".php" }
This will work in PowerShell. If you have Windows 7 or Vista, you should have it installed by default. If you are on XP you can download it here.
edited Jan 31 '16 at 1:36
G-Man
5,627112358
5,627112358
answered Mar 21 '12 at 11:12
soandossoandos
20.2k2892130
20.2k2892130
Soandos, Chapeau !!!!!!!!!!!! Many thanx from this side, works like a charm.
– Charles
Mar 21 '12 at 11:31
@Charles, if this solved your problem, please click the check mark, so that everyone else that sees it will know it worked. Welcome to SuperUser.
– soandos
Mar 21 '12 at 11:33
add a comment |
Soandos, Chapeau !!!!!!!!!!!! Many thanx from this side, works like a charm.
– Charles
Mar 21 '12 at 11:31
@Charles, if this solved your problem, please click the check mark, so that everyone else that sees it will know it worked. Welcome to SuperUser.
– soandos
Mar 21 '12 at 11:33
Soandos, Chapeau !!!!!!!!!!!! Many thanx from this side, works like a charm.
– Charles
Mar 21 '12 at 11:31
Soandos, Chapeau !!!!!!!!!!!! Many thanx from this side, works like a charm.
– Charles
Mar 21 '12 at 11:31
@Charles, if this solved your problem, please click the check mark, so that everyone else that sees it will know it worked. Welcome to SuperUser.
– soandos
Mar 21 '12 at 11:33
@Charles, if this solved your problem, please click the check mark, so that everyone else that sees it will know it worked. Welcome to SuperUser.
– soandos
Mar 21 '12 at 11:33
add a comment |
In command line:
for /f "delims=*" %a in ('dir *.html /b /s') do ren "%a" *.php
Note: You can replace *.html
for other wildcard, e.g. d:www*.html
.
Note 2: If using the command within a batch file, replace %a
with %%a
(don't ask me why)
Why do you say"delims=*"
?"delims="
should be good enough (i.e., why do you specify a delimiter of*
?
– G-Man
Jan 31 '16 at 1:34
add a comment |
In command line:
for /f "delims=*" %a in ('dir *.html /b /s') do ren "%a" *.php
Note: You can replace *.html
for other wildcard, e.g. d:www*.html
.
Note 2: If using the command within a batch file, replace %a
with %%a
(don't ask me why)
Why do you say"delims=*"
?"delims="
should be good enough (i.e., why do you specify a delimiter of*
?
– G-Man
Jan 31 '16 at 1:34
add a comment |
In command line:
for /f "delims=*" %a in ('dir *.html /b /s') do ren "%a" *.php
Note: You can replace *.html
for other wildcard, e.g. d:www*.html
.
Note 2: If using the command within a batch file, replace %a
with %%a
(don't ask me why)
In command line:
for /f "delims=*" %a in ('dir *.html /b /s') do ren "%a" *.php
Note: You can replace *.html
for other wildcard, e.g. d:www*.html
.
Note 2: If using the command within a batch file, replace %a
with %%a
(don't ask me why)
edited Mar 22 '12 at 11:40
slhck
161k47447470
161k47447470
answered Mar 21 '12 at 11:20
ZEDA-NLZEDA-NL
393210
393210
Why do you say"delims=*"
?"delims="
should be good enough (i.e., why do you specify a delimiter of*
?
– G-Man
Jan 31 '16 at 1:34
add a comment |
Why do you say"delims=*"
?"delims="
should be good enough (i.e., why do you specify a delimiter of*
?
– G-Man
Jan 31 '16 at 1:34
Why do you say
"delims=*"
? "delims="
should be good enough (i.e., why do you specify a delimiter of *
?– G-Man
Jan 31 '16 at 1:34
Why do you say
"delims=*"
? "delims="
should be good enough (i.e., why do you specify a delimiter of *
?– G-Man
Jan 31 '16 at 1:34
add a comment |
Flexible Renamer is an excellent little program that will handle several different types of renaming searches/replaces. It accepts regular expressions, and has common patterns predefined. Additionally, it allows you to include items in subfolders, or operate on folders themselves. It also gives you a preview of all changes that will be made. I have used it for years, and highly recommend it.
http://download.cnet.com/Flexible-Renamer/3000-2248_4-28799.html
This made my day ! Thanks so much !
– Shaig Khaligli
Dec 8 '18 at 12:32
add a comment |
Flexible Renamer is an excellent little program that will handle several different types of renaming searches/replaces. It accepts regular expressions, and has common patterns predefined. Additionally, it allows you to include items in subfolders, or operate on folders themselves. It also gives you a preview of all changes that will be made. I have used it for years, and highly recommend it.
http://download.cnet.com/Flexible-Renamer/3000-2248_4-28799.html
This made my day ! Thanks so much !
– Shaig Khaligli
Dec 8 '18 at 12:32
add a comment |
Flexible Renamer is an excellent little program that will handle several different types of renaming searches/replaces. It accepts regular expressions, and has common patterns predefined. Additionally, it allows you to include items in subfolders, or operate on folders themselves. It also gives you a preview of all changes that will be made. I have used it for years, and highly recommend it.
http://download.cnet.com/Flexible-Renamer/3000-2248_4-28799.html
Flexible Renamer is an excellent little program that will handle several different types of renaming searches/replaces. It accepts regular expressions, and has common patterns predefined. Additionally, it allows you to include items in subfolders, or operate on folders themselves. It also gives you a preview of all changes that will be made. I have used it for years, and highly recommend it.
http://download.cnet.com/Flexible-Renamer/3000-2248_4-28799.html
answered Mar 21 '12 at 13:33
AaronAaron
266
266
This made my day ! Thanks so much !
– Shaig Khaligli
Dec 8 '18 at 12:32
add a comment |
This made my day ! Thanks so much !
– Shaig Khaligli
Dec 8 '18 at 12:32
This made my day ! Thanks so much !
– Shaig Khaligli
Dec 8 '18 at 12:32
This made my day ! Thanks so much !
– Shaig Khaligli
Dec 8 '18 at 12:32
add a comment |
Using forfiles, we can write a script, to rename files recursively in all subfolders.
forfiles /S /M *.html /C "cmd /c rename @file @fname.php"
Source: Batch script for renaming files in bulk
add a comment |
Using forfiles, we can write a script, to rename files recursively in all subfolders.
forfiles /S /M *.html /C "cmd /c rename @file @fname.php"
Source: Batch script for renaming files in bulk
add a comment |
Using forfiles, we can write a script, to rename files recursively in all subfolders.
forfiles /S /M *.html /C "cmd /c rename @file @fname.php"
Source: Batch script for renaming files in bulk
Using forfiles, we can write a script, to rename files recursively in all subfolders.
forfiles /S /M *.html /C "cmd /c rename @file @fname.php"
Source: Batch script for renaming files in bulk
answered Jun 19 '12 at 16:38
SriniSrini
111
111
add a comment |
add a comment |
TotalCommander: Search - Send to Panel - Multi-Rename Tool
add a comment |
TotalCommander: Search - Send to Panel - Multi-Rename Tool
add a comment |
TotalCommander: Search - Send to Panel - Multi-Rename Tool
TotalCommander: Search - Send to Panel - Multi-Rename Tool
edited Mar 28 '12 at 17:22
Raystafarian
19.5k105089
19.5k105089
answered Mar 21 '12 at 17:40
Lazy BadgerLazy Badger
3,471912
3,471912
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.
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%2f403183%2fhow-to-rename-multiple-files-in-multiple-folders-with-one-command%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