Batch rename MODIS data?
I have MOD13Q1 NDVI images. Data are named in this format:
MOD13Q1.A2007049.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
(YYYYDDD) Here 2007 is a year and 049 is day in year.
I have to rename it in this format: (YYYY.MM.DD) 2007.02.18
I am renaming it manually for every single file. How to perform a batch process for renaming all the files?
r modis batch date string
add a comment |
I have MOD13Q1 NDVI images. Data are named in this format:
MOD13Q1.A2007049.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
(YYYYDDD) Here 2007 is a year and 049 is day in year.
I have to rename it in this format: (YYYY.MM.DD) 2007.02.18
I am renaming it manually for every single file. How to perform a batch process for renaming all the files?
r modis batch date string
add a comment |
I have MOD13Q1 NDVI images. Data are named in this format:
MOD13Q1.A2007049.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
(YYYYDDD) Here 2007 is a year and 049 is day in year.
I have to rename it in this format: (YYYY.MM.DD) 2007.02.18
I am renaming it manually for every single file. How to perform a batch process for renaming all the files?
r modis batch date string
I have MOD13Q1 NDVI images. Data are named in this format:
MOD13Q1.A2007049.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
(YYYYDDD) Here 2007 is a year and 049 is day in year.
I have to rename it in this format: (YYYY.MM.DD) 2007.02.18
I am renaming it manually for every single file. How to perform a batch process for renaming all the files?
r modis batch date string
r modis batch date string
edited 24 mins ago
Andre Silva
7,105113578
7,105113578
asked 5 hours ago
Tilok Chetri
145
145
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
If you were to use R language (open source), this will work.
setwd("C:/modis") #path of modis files
li<-as.data.frame(list.files(pattern = ".tif|.TIF"))
li$nn<-paste0(substr(li[,1],1,9),format(as.Date(substr(li[,1],10,16), "%Y%j"),"%Y.%m.%d"),substr(li[,1],17,75))
for(i in 1:nrow(li)){
file.rename(as.character(li[i,1]),li[i,2])
}
add a comment |
Suppose the following files:
MOD13Q1.A2007049.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
MOD13Q1.A2007051.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
and that they are stored in directory C:/modis_files
Run:
setwd('C:\modis_files') #path to folder where MODIS files are.
file.rename(list.files(), paste(as.Date(substr(list.files(),10,16),"%Y%j"),".tif", sep=""))
It will result in:
2007-02-18.tif
2007-02-20.tif
If you want to keep the entire file name, while only replacing the [year + julian days], then Bharadwaj A K's answer is the one.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2fgis.stackexchange.com%2fquestions%2f307324%2fbatch-rename-modis-data%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you were to use R language (open source), this will work.
setwd("C:/modis") #path of modis files
li<-as.data.frame(list.files(pattern = ".tif|.TIF"))
li$nn<-paste0(substr(li[,1],1,9),format(as.Date(substr(li[,1],10,16), "%Y%j"),"%Y.%m.%d"),substr(li[,1],17,75))
for(i in 1:nrow(li)){
file.rename(as.character(li[i,1]),li[i,2])
}
add a comment |
If you were to use R language (open source), this will work.
setwd("C:/modis") #path of modis files
li<-as.data.frame(list.files(pattern = ".tif|.TIF"))
li$nn<-paste0(substr(li[,1],1,9),format(as.Date(substr(li[,1],10,16), "%Y%j"),"%Y.%m.%d"),substr(li[,1],17,75))
for(i in 1:nrow(li)){
file.rename(as.character(li[i,1]),li[i,2])
}
add a comment |
If you were to use R language (open source), this will work.
setwd("C:/modis") #path of modis files
li<-as.data.frame(list.files(pattern = ".tif|.TIF"))
li$nn<-paste0(substr(li[,1],1,9),format(as.Date(substr(li[,1],10,16), "%Y%j"),"%Y.%m.%d"),substr(li[,1],17,75))
for(i in 1:nrow(li)){
file.rename(as.character(li[i,1]),li[i,2])
}
If you were to use R language (open source), this will work.
setwd("C:/modis") #path of modis files
li<-as.data.frame(list.files(pattern = ".tif|.TIF"))
li$nn<-paste0(substr(li[,1],1,9),format(as.Date(substr(li[,1],10,16), "%Y%j"),"%Y.%m.%d"),substr(li[,1],17,75))
for(i in 1:nrow(li)){
file.rename(as.character(li[i,1]),li[i,2])
}
answered 1 hour ago
Bharadwaj A K
373
373
add a comment |
add a comment |
Suppose the following files:
MOD13Q1.A2007049.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
MOD13Q1.A2007051.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
and that they are stored in directory C:/modis_files
Run:
setwd('C:\modis_files') #path to folder where MODIS files are.
file.rename(list.files(), paste(as.Date(substr(list.files(),10,16),"%Y%j"),".tif", sep=""))
It will result in:
2007-02-18.tif
2007-02-20.tif
If you want to keep the entire file name, while only replacing the [year + julian days], then Bharadwaj A K's answer is the one.
add a comment |
Suppose the following files:
MOD13Q1.A2007049.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
MOD13Q1.A2007051.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
and that they are stored in directory C:/modis_files
Run:
setwd('C:\modis_files') #path to folder where MODIS files are.
file.rename(list.files(), paste(as.Date(substr(list.files(),10,16),"%Y%j"),".tif", sep=""))
It will result in:
2007-02-18.tif
2007-02-20.tif
If you want to keep the entire file name, while only replacing the [year + julian days], then Bharadwaj A K's answer is the one.
add a comment |
Suppose the following files:
MOD13Q1.A2007049.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
MOD13Q1.A2007051.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
and that they are stored in directory C:/modis_files
Run:
setwd('C:\modis_files') #path to folder where MODIS files are.
file.rename(list.files(), paste(as.Date(substr(list.files(),10,16),"%Y%j"),".tif", sep=""))
It will result in:
2007-02-18.tif
2007-02-20.tif
If you want to keep the entire file name, while only replacing the [year + julian days], then Bharadwaj A K's answer is the one.
Suppose the following files:
MOD13Q1.A2007049.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
MOD13Q1.A2007051.h26v06.006.2015161224938_MODIS_Grid_16DAY_250m_500m_VI.tif
and that they are stored in directory C:/modis_files
Run:
setwd('C:\modis_files') #path to folder where MODIS files are.
file.rename(list.files(), paste(as.Date(substr(list.files(),10,16),"%Y%j"),".tif", sep=""))
It will result in:
2007-02-18.tif
2007-02-20.tif
If you want to keep the entire file name, while only replacing the [year + julian days], then Bharadwaj A K's answer is the one.
edited 27 mins ago
answered 42 mins ago
Andre Silva
7,105113578
7,105113578
add a comment |
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- 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%2fgis.stackexchange.com%2fquestions%2f307324%2fbatch-rename-modis-data%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