Windows 7 script to change part of a file nameHow to preserve diacritics when cross-mounting drives to...
Touchscreen-controlled dentist office snowman collector game
Single word request: Harming the benefactor
Life insurance that covers only simultaneous/dual deaths
The three point beverage
How to deal with a cynical class?
Can infringement of a trademark be pursued for using a company's name in a sentence?
It's a yearly task, alright
How can I discourage/prevent PCs from using door choke-points?
What is the likely impact on flights of grounding an entire aircraft series?
Do f-stop and exposure time perfectly cancel?
Welcoming 2019 Pi day: How to draw the letter π?
What Happens when Passenger Refuses to Fly Boeing 737 Max?
As a monk, can you make a melee attack roll using your Strength modifier, but roll damage with your Dexterity modifier?
What does it mean when multiple 々 marks follow a 、?
Running a subshell from the middle of the current command
Is it illegal in Germany to take sick leave if you caused your own illness with food?
Ban on all campaign finance?
Deleting missing values from a dataset
How could a female member of a species produce eggs unto death?
What injury would be of little consequence to a biped but terrible for a quadruped?
What has been your most complicated TikZ drawing?
If Invisibility ends because the original caster casts a non-concentration spell, does Invisibility also end on other targets of the original casting?
What happens with multiple copies of Humility and Glorious Anthem on the battlefield?
Is a lawful good "antagonist" effective?
Windows 7 script to change part of a file name
How to preserve diacritics when cross-mounting drives to Windows7 and LinuxHow to automatically change file names for all file added to a directory?Add text to end of filename (but before extension) using batch fileDetect duplicate file name with different extensionVBS or batch for identifying folders with more than two wordsHow can I rename files in directory, while keeping part of the name unchanged?How can I recursively rename files with this batch script?Bash script I need to rename files in bash so first part of filename is moved ot last part of filenameBatch File: Loop Not Outputting Inputted Variable Value to External FileHow to rename mutiple images using .bat file with some conditions?
I have a collection of files whose names are in the form car-#######-NNNNNNN.xxx
,
where #######
is a series of numbers that need to be kept as part of the file name,
and xxx
is an extension denoting the file format, such as "jpg", "bmp", or "png",
which also needs to be kept.
I need to remove the car-
and the -NNNNNNN
(duplication of the -#######
) from the file name,
leaving only #######.xxx
.
Is this possible and how could I do this?
windows-7 windows batch script batch-rename
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have a collection of files whose names are in the form car-#######-NNNNNNN.xxx
,
where #######
is a series of numbers that need to be kept as part of the file name,
and xxx
is an extension denoting the file format, such as "jpg", "bmp", or "png",
which also needs to be kept.
I need to remove the car-
and the -NNNNNNN
(duplication of the -#######
) from the file name,
leaving only #######.xxx
.
Is this possible and how could I do this?
windows-7 windows batch script batch-rename
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have a collection of files whose names are in the form car-#######-NNNNNNN.xxx
,
where #######
is a series of numbers that need to be kept as part of the file name,
and xxx
is an extension denoting the file format, such as "jpg", "bmp", or "png",
which also needs to be kept.
I need to remove the car-
and the -NNNNNNN
(duplication of the -#######
) from the file name,
leaving only #######.xxx
.
Is this possible and how could I do this?
windows-7 windows batch script batch-rename
I have a collection of files whose names are in the form car-#######-NNNNNNN.xxx
,
where #######
is a series of numbers that need to be kept as part of the file name,
and xxx
is an extension denoting the file format, such as "jpg", "bmp", or "png",
which also needs to be kept.
I need to remove the car-
and the -NNNNNNN
(duplication of the -#######
) from the file name,
leaving only #######.xxx
.
Is this possible and how could I do this?
windows-7 windows batch script batch-rename
windows-7 windows batch script batch-rename
edited Sep 17 '14 at 16:58
G-Man
5,647112359
5,647112359
asked Sep 8 '14 at 5:58
ObsidianObsidian
11
11
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Copy this text into a text editor (Notepad) and save the file as rename.bat
into the folder where the files are located and run it.
Change xxx
in the line IF %ext% EQU xxx ren %1 "%fnum%.%ext%"
to whatever extension your files are saved in.
@ECHO OFF
for /f "tokens=*" %%i ^
in ('forfiles /d +0 /c "cmd /c if @isdir==FALSE echo @file"') ^
do call :subroutine %%i
pause
:subroutine
set fname=%1
set ext=%fname:~-4,3%
set fnum=%fname:~5,7%
REM echo %fnum%
REM echo %ext%
IF %ext% EQU xxx ren %1 "%fnum%.%ext%"
add a comment |
Windows file manager does not provide complex multiple file renaming functionality with use of patterns or regular expressions (unlike normal file managers do).
I would recommend doing the job under linux if you have a linux distro available. Just use Nautilus and you will be able to mass-rename and use pattern-based search/replace functionality.
Alternatively, if you don't have access to linux distro, try to install Total Commander. This file manager has good mass-renaming functionality. You can alos read a nice guide on this page.
I think he's looking for a batch script to achieve this as the question says "Windows 7 script..."
– Vinayak
Sep 8 '14 at 13:08
@Vinayak, correct, however I thought that using a file manager like TC could be an acceptable solution to the actual problem. Its up to OP to decide what is best for him.
– Art Gertner
Sep 8 '14 at 13:11
Oops, my bad. I hadn't read the part about Total Commander. I'd also like to add that ReNamer is a pretty good tool to consider, if all the OP wants is to rename stuff.
– Vinayak
Sep 8 '14 at 13:15
add a comment |
Vinayak’s answer looks OK if your #######
is always exactly seven characters.
If the number of characters can vary, and you want to work by delimiter rather than count, try
for /f "delims=-. tokens=1-4" %a in ('dir /b/a-d car-*-*.*') ^
do @echo ren %a-%b-%c.%d %b.%d
Run this, and, if it shows you the correct rename commands,
delete the echo
and run it again.
I split this into two lines so it would fit on the screen;
if you prefer, you can make it all one line (delete the ^
).
If you put this into a script (batch file), change all occurrences of %
to %%
.
Warning: if your NNNNNNN
is not always a duplicate of your #######
,
e.g., you have files named car-1234567-1234567.jpg
and car-1234567-9999999.jpg
,
this will rename the first one it finds and give error messages for the others.
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%2f808632%2fwindows-7-script-to-change-part-of-a-file-name%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Copy this text into a text editor (Notepad) and save the file as rename.bat
into the folder where the files are located and run it.
Change xxx
in the line IF %ext% EQU xxx ren %1 "%fnum%.%ext%"
to whatever extension your files are saved in.
@ECHO OFF
for /f "tokens=*" %%i ^
in ('forfiles /d +0 /c "cmd /c if @isdir==FALSE echo @file"') ^
do call :subroutine %%i
pause
:subroutine
set fname=%1
set ext=%fname:~-4,3%
set fnum=%fname:~5,7%
REM echo %fnum%
REM echo %ext%
IF %ext% EQU xxx ren %1 "%fnum%.%ext%"
add a comment |
Copy this text into a text editor (Notepad) and save the file as rename.bat
into the folder where the files are located and run it.
Change xxx
in the line IF %ext% EQU xxx ren %1 "%fnum%.%ext%"
to whatever extension your files are saved in.
@ECHO OFF
for /f "tokens=*" %%i ^
in ('forfiles /d +0 /c "cmd /c if @isdir==FALSE echo @file"') ^
do call :subroutine %%i
pause
:subroutine
set fname=%1
set ext=%fname:~-4,3%
set fnum=%fname:~5,7%
REM echo %fnum%
REM echo %ext%
IF %ext% EQU xxx ren %1 "%fnum%.%ext%"
add a comment |
Copy this text into a text editor (Notepad) and save the file as rename.bat
into the folder where the files are located and run it.
Change xxx
in the line IF %ext% EQU xxx ren %1 "%fnum%.%ext%"
to whatever extension your files are saved in.
@ECHO OFF
for /f "tokens=*" %%i ^
in ('forfiles /d +0 /c "cmd /c if @isdir==FALSE echo @file"') ^
do call :subroutine %%i
pause
:subroutine
set fname=%1
set ext=%fname:~-4,3%
set fnum=%fname:~5,7%
REM echo %fnum%
REM echo %ext%
IF %ext% EQU xxx ren %1 "%fnum%.%ext%"
Copy this text into a text editor (Notepad) and save the file as rename.bat
into the folder where the files are located and run it.
Change xxx
in the line IF %ext% EQU xxx ren %1 "%fnum%.%ext%"
to whatever extension your files are saved in.
@ECHO OFF
for /f "tokens=*" %%i ^
in ('forfiles /d +0 /c "cmd /c if @isdir==FALSE echo @file"') ^
do call :subroutine %%i
pause
:subroutine
set fname=%1
set ext=%fname:~-4,3%
set fnum=%fname:~5,7%
REM echo %fnum%
REM echo %ext%
IF %ext% EQU xxx ren %1 "%fnum%.%ext%"
answered Sep 8 '14 at 7:17
VinayakVinayak
8,63044074
8,63044074
add a comment |
add a comment |
Windows file manager does not provide complex multiple file renaming functionality with use of patterns or regular expressions (unlike normal file managers do).
I would recommend doing the job under linux if you have a linux distro available. Just use Nautilus and you will be able to mass-rename and use pattern-based search/replace functionality.
Alternatively, if you don't have access to linux distro, try to install Total Commander. This file manager has good mass-renaming functionality. You can alos read a nice guide on this page.
I think he's looking for a batch script to achieve this as the question says "Windows 7 script..."
– Vinayak
Sep 8 '14 at 13:08
@Vinayak, correct, however I thought that using a file manager like TC could be an acceptable solution to the actual problem. Its up to OP to decide what is best for him.
– Art Gertner
Sep 8 '14 at 13:11
Oops, my bad. I hadn't read the part about Total Commander. I'd also like to add that ReNamer is a pretty good tool to consider, if all the OP wants is to rename stuff.
– Vinayak
Sep 8 '14 at 13:15
add a comment |
Windows file manager does not provide complex multiple file renaming functionality with use of patterns or regular expressions (unlike normal file managers do).
I would recommend doing the job under linux if you have a linux distro available. Just use Nautilus and you will be able to mass-rename and use pattern-based search/replace functionality.
Alternatively, if you don't have access to linux distro, try to install Total Commander. This file manager has good mass-renaming functionality. You can alos read a nice guide on this page.
I think he's looking for a batch script to achieve this as the question says "Windows 7 script..."
– Vinayak
Sep 8 '14 at 13:08
@Vinayak, correct, however I thought that using a file manager like TC could be an acceptable solution to the actual problem. Its up to OP to decide what is best for him.
– Art Gertner
Sep 8 '14 at 13:11
Oops, my bad. I hadn't read the part about Total Commander. I'd also like to add that ReNamer is a pretty good tool to consider, if all the OP wants is to rename stuff.
– Vinayak
Sep 8 '14 at 13:15
add a comment |
Windows file manager does not provide complex multiple file renaming functionality with use of patterns or regular expressions (unlike normal file managers do).
I would recommend doing the job under linux if you have a linux distro available. Just use Nautilus and you will be able to mass-rename and use pattern-based search/replace functionality.
Alternatively, if you don't have access to linux distro, try to install Total Commander. This file manager has good mass-renaming functionality. You can alos read a nice guide on this page.
Windows file manager does not provide complex multiple file renaming functionality with use of patterns or regular expressions (unlike normal file managers do).
I would recommend doing the job under linux if you have a linux distro available. Just use Nautilus and you will be able to mass-rename and use pattern-based search/replace functionality.
Alternatively, if you don't have access to linux distro, try to install Total Commander. This file manager has good mass-renaming functionality. You can alos read a nice guide on this page.
answered Sep 8 '14 at 7:39
Art GertnerArt Gertner
5,966113663
5,966113663
I think he's looking for a batch script to achieve this as the question says "Windows 7 script..."
– Vinayak
Sep 8 '14 at 13:08
@Vinayak, correct, however I thought that using a file manager like TC could be an acceptable solution to the actual problem. Its up to OP to decide what is best for him.
– Art Gertner
Sep 8 '14 at 13:11
Oops, my bad. I hadn't read the part about Total Commander. I'd also like to add that ReNamer is a pretty good tool to consider, if all the OP wants is to rename stuff.
– Vinayak
Sep 8 '14 at 13:15
add a comment |
I think he's looking for a batch script to achieve this as the question says "Windows 7 script..."
– Vinayak
Sep 8 '14 at 13:08
@Vinayak, correct, however I thought that using a file manager like TC could be an acceptable solution to the actual problem. Its up to OP to decide what is best for him.
– Art Gertner
Sep 8 '14 at 13:11
Oops, my bad. I hadn't read the part about Total Commander. I'd also like to add that ReNamer is a pretty good tool to consider, if all the OP wants is to rename stuff.
– Vinayak
Sep 8 '14 at 13:15
I think he's looking for a batch script to achieve this as the question says "Windows 7 script..."
– Vinayak
Sep 8 '14 at 13:08
I think he's looking for a batch script to achieve this as the question says "Windows 7 script..."
– Vinayak
Sep 8 '14 at 13:08
@Vinayak, correct, however I thought that using a file manager like TC could be an acceptable solution to the actual problem. Its up to OP to decide what is best for him.
– Art Gertner
Sep 8 '14 at 13:11
@Vinayak, correct, however I thought that using a file manager like TC could be an acceptable solution to the actual problem. Its up to OP to decide what is best for him.
– Art Gertner
Sep 8 '14 at 13:11
Oops, my bad. I hadn't read the part about Total Commander. I'd also like to add that ReNamer is a pretty good tool to consider, if all the OP wants is to rename stuff.
– Vinayak
Sep 8 '14 at 13:15
Oops, my bad. I hadn't read the part about Total Commander. I'd also like to add that ReNamer is a pretty good tool to consider, if all the OP wants is to rename stuff.
– Vinayak
Sep 8 '14 at 13:15
add a comment |
Vinayak’s answer looks OK if your #######
is always exactly seven characters.
If the number of characters can vary, and you want to work by delimiter rather than count, try
for /f "delims=-. tokens=1-4" %a in ('dir /b/a-d car-*-*.*') ^
do @echo ren %a-%b-%c.%d %b.%d
Run this, and, if it shows you the correct rename commands,
delete the echo
and run it again.
I split this into two lines so it would fit on the screen;
if you prefer, you can make it all one line (delete the ^
).
If you put this into a script (batch file), change all occurrences of %
to %%
.
Warning: if your NNNNNNN
is not always a duplicate of your #######
,
e.g., you have files named car-1234567-1234567.jpg
and car-1234567-9999999.jpg
,
this will rename the first one it finds and give error messages for the others.
add a comment |
Vinayak’s answer looks OK if your #######
is always exactly seven characters.
If the number of characters can vary, and you want to work by delimiter rather than count, try
for /f "delims=-. tokens=1-4" %a in ('dir /b/a-d car-*-*.*') ^
do @echo ren %a-%b-%c.%d %b.%d
Run this, and, if it shows you the correct rename commands,
delete the echo
and run it again.
I split this into two lines so it would fit on the screen;
if you prefer, you can make it all one line (delete the ^
).
If you put this into a script (batch file), change all occurrences of %
to %%
.
Warning: if your NNNNNNN
is not always a duplicate of your #######
,
e.g., you have files named car-1234567-1234567.jpg
and car-1234567-9999999.jpg
,
this will rename the first one it finds and give error messages for the others.
add a comment |
Vinayak’s answer looks OK if your #######
is always exactly seven characters.
If the number of characters can vary, and you want to work by delimiter rather than count, try
for /f "delims=-. tokens=1-4" %a in ('dir /b/a-d car-*-*.*') ^
do @echo ren %a-%b-%c.%d %b.%d
Run this, and, if it shows you the correct rename commands,
delete the echo
and run it again.
I split this into two lines so it would fit on the screen;
if you prefer, you can make it all one line (delete the ^
).
If you put this into a script (batch file), change all occurrences of %
to %%
.
Warning: if your NNNNNNN
is not always a duplicate of your #######
,
e.g., you have files named car-1234567-1234567.jpg
and car-1234567-9999999.jpg
,
this will rename the first one it finds and give error messages for the others.
Vinayak’s answer looks OK if your #######
is always exactly seven characters.
If the number of characters can vary, and you want to work by delimiter rather than count, try
for /f "delims=-. tokens=1-4" %a in ('dir /b/a-d car-*-*.*') ^
do @echo ren %a-%b-%c.%d %b.%d
Run this, and, if it shows you the correct rename commands,
delete the echo
and run it again.
I split this into two lines so it would fit on the screen;
if you prefer, you can make it all one line (delete the ^
).
If you put this into a script (batch file), change all occurrences of %
to %%
.
Warning: if your NNNNNNN
is not always a duplicate of your #######
,
e.g., you have files named car-1234567-1234567.jpg
and car-1234567-9999999.jpg
,
this will rename the first one it finds and give error messages for the others.
answered Sep 17 '14 at 17:02
ScottScott
15.9k113990
15.9k113990
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%2f808632%2fwindows-7-script-to-change-part-of-a-file-name%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