What about privacy ? :)

Sign by Danasoft - For Backgrounds and Layouts

lunedì 17 dicembre 2012

How to change (a lot of) system file names with R


Imagine you need to change (a lot of) file names for you work or simply to rename you music files collection.
I wrote a code that does the job with the programming language R (www.r-project.com) as you can see in the following:

# first set your working directory
setwd("~/my_directory")

# read file names and store them in an object (created on the fly)
(listafiles<- list.files())

#inspect the just created object
head(listafiles)
str(listafiles) #246 elementi
grep(pattern="[2011]", listafiles) #246 nomi contengono 2011 (365-246=119 giorni mancanti)

TO BE CONTINUED .....

#final check
head(listafiles,15)
head(lista_new,15)
tail(listafiles)
tail(lista_new)
nchar(listafiles)
nchar(lista_new)
sum(is.na(lista_new))

Nessun commento:

Posta un commento