debian rename regex to alter filename
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
sort of stuck here. I have pictures in a directory on debian (stretch, rename installed; with nextcloud running on it) with photos from one skiing trip, taken from my phone (Android Moto G5, filenames IMG_20190202...
) and my girlfriend's phone (iPhone 5, filenames 19-02-02...
). Since nextcloud can't sort by exif-data, it makes sense to have a constant photo-naming scheme to sort by this (and thereby by date). I figured I'd like to use rename
, but can't figure out how to reach the following:
19-02-02 16-05-45 4094.jpg => IMG_20190202_160545 4094.jpg
(the suffix number, e.g. "4094", is supposed to stay to see at first glance who took the picture)
problems:
a) insert IMG_20
where there is none. This already throws me off, since rename -n 's/[^IMG_]/IMG_20/' 19-02-02 16-05-45 4094.jpg
produces IMG_209-02-02 16-05-45 4094.jpg
(with the 1
of 2019
missing). How do alter the replacement to include the first character it finds?
b) remove all occurences of -
and replace the first space
with -
. No idea how about to do this...
Any help is appreciated!
EDIT:
I have found sort of a solution. But it consists of three steps (and a fourth one is needed, I'm afraid):
1) rename -n 's/^([^IMG_])/IMG_20$1/' *.jpg
2) rename -n 's/-//g' *.jpg
3) rename -n 's/ /_/' *.jpg
NEW PROBLEM: nextcloud (or windows explorer) still doesn't sort correctly, since the images taken by the Moto have 3 digits added to the TIME, e.g. a picture taken at 13h06min47sec. is called ...130547123.jpg. This is a larger number than ...200510... for example (a picture taken on 20h05min10sec), hence it is listed later. So I need a regex to delete the three digits in pos. 20,21,22 in these files! But in the iPhone pictures, this would delete the four digit group that makes it possible to distinguish between pictures taken by the Moto and pictures taken by the iPhone... :-(
linux bash debian regex rename
add a comment |
sort of stuck here. I have pictures in a directory on debian (stretch, rename installed; with nextcloud running on it) with photos from one skiing trip, taken from my phone (Android Moto G5, filenames IMG_20190202...
) and my girlfriend's phone (iPhone 5, filenames 19-02-02...
). Since nextcloud can't sort by exif-data, it makes sense to have a constant photo-naming scheme to sort by this (and thereby by date). I figured I'd like to use rename
, but can't figure out how to reach the following:
19-02-02 16-05-45 4094.jpg => IMG_20190202_160545 4094.jpg
(the suffix number, e.g. "4094", is supposed to stay to see at first glance who took the picture)
problems:
a) insert IMG_20
where there is none. This already throws me off, since rename -n 's/[^IMG_]/IMG_20/' 19-02-02 16-05-45 4094.jpg
produces IMG_209-02-02 16-05-45 4094.jpg
(with the 1
of 2019
missing). How do alter the replacement to include the first character it finds?
b) remove all occurences of -
and replace the first space
with -
. No idea how about to do this...
Any help is appreciated!
EDIT:
I have found sort of a solution. But it consists of three steps (and a fourth one is needed, I'm afraid):
1) rename -n 's/^([^IMG_])/IMG_20$1/' *.jpg
2) rename -n 's/-//g' *.jpg
3) rename -n 's/ /_/' *.jpg
NEW PROBLEM: nextcloud (or windows explorer) still doesn't sort correctly, since the images taken by the Moto have 3 digits added to the TIME, e.g. a picture taken at 13h06min47sec. is called ...130547123.jpg. This is a larger number than ...200510... for example (a picture taken on 20h05min10sec), hence it is listed later. So I need a regex to delete the three digits in pos. 20,21,22 in these files! But in the iPhone pictures, this would delete the four digit group that makes it possible to distinguish between pictures taken by the Moto and pictures taken by the iPhone... :-(
linux bash debian regex rename
add a comment |
sort of stuck here. I have pictures in a directory on debian (stretch, rename installed; with nextcloud running on it) with photos from one skiing trip, taken from my phone (Android Moto G5, filenames IMG_20190202...
) and my girlfriend's phone (iPhone 5, filenames 19-02-02...
). Since nextcloud can't sort by exif-data, it makes sense to have a constant photo-naming scheme to sort by this (and thereby by date). I figured I'd like to use rename
, but can't figure out how to reach the following:
19-02-02 16-05-45 4094.jpg => IMG_20190202_160545 4094.jpg
(the suffix number, e.g. "4094", is supposed to stay to see at first glance who took the picture)
problems:
a) insert IMG_20
where there is none. This already throws me off, since rename -n 's/[^IMG_]/IMG_20/' 19-02-02 16-05-45 4094.jpg
produces IMG_209-02-02 16-05-45 4094.jpg
(with the 1
of 2019
missing). How do alter the replacement to include the first character it finds?
b) remove all occurences of -
and replace the first space
with -
. No idea how about to do this...
Any help is appreciated!
EDIT:
I have found sort of a solution. But it consists of three steps (and a fourth one is needed, I'm afraid):
1) rename -n 's/^([^IMG_])/IMG_20$1/' *.jpg
2) rename -n 's/-//g' *.jpg
3) rename -n 's/ /_/' *.jpg
NEW PROBLEM: nextcloud (or windows explorer) still doesn't sort correctly, since the images taken by the Moto have 3 digits added to the TIME, e.g. a picture taken at 13h06min47sec. is called ...130547123.jpg. This is a larger number than ...200510... for example (a picture taken on 20h05min10sec), hence it is listed later. So I need a regex to delete the three digits in pos. 20,21,22 in these files! But in the iPhone pictures, this would delete the four digit group that makes it possible to distinguish between pictures taken by the Moto and pictures taken by the iPhone... :-(
linux bash debian regex rename
sort of stuck here. I have pictures in a directory on debian (stretch, rename installed; with nextcloud running on it) with photos from one skiing trip, taken from my phone (Android Moto G5, filenames IMG_20190202...
) and my girlfriend's phone (iPhone 5, filenames 19-02-02...
). Since nextcloud can't sort by exif-data, it makes sense to have a constant photo-naming scheme to sort by this (and thereby by date). I figured I'd like to use rename
, but can't figure out how to reach the following:
19-02-02 16-05-45 4094.jpg => IMG_20190202_160545 4094.jpg
(the suffix number, e.g. "4094", is supposed to stay to see at first glance who took the picture)
problems:
a) insert IMG_20
where there is none. This already throws me off, since rename -n 's/[^IMG_]/IMG_20/' 19-02-02 16-05-45 4094.jpg
produces IMG_209-02-02 16-05-45 4094.jpg
(with the 1
of 2019
missing). How do alter the replacement to include the first character it finds?
b) remove all occurences of -
and replace the first space
with -
. No idea how about to do this...
Any help is appreciated!
EDIT:
I have found sort of a solution. But it consists of three steps (and a fourth one is needed, I'm afraid):
1) rename -n 's/^([^IMG_])/IMG_20$1/' *.jpg
2) rename -n 's/-//g' *.jpg
3) rename -n 's/ /_/' *.jpg
NEW PROBLEM: nextcloud (or windows explorer) still doesn't sort correctly, since the images taken by the Moto have 3 digits added to the TIME, e.g. a picture taken at 13h06min47sec. is called ...130547123.jpg. This is a larger number than ...200510... for example (a picture taken on 20h05min10sec), hence it is listed later. So I need a regex to delete the three digits in pos. 20,21,22 in these files! But in the iPhone pictures, this would delete the four digit group that makes it possible to distinguish between pictures taken by the Moto and pictures taken by the iPhone... :-(
linux bash debian regex rename
linux bash debian regex rename
edited Feb 11 at 21:28
Beres
asked Feb 11 at 19:26
BeresBeres
12
12
add a comment |
add a comment |
0
active
oldest
votes
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%2f1404562%2fdebian-rename-regex-to-alter-filename%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f1404562%2fdebian-rename-regex-to-alter-filename%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