As a result from a loop I have a lot of files without a file extension in a folder.
How could I add a file extension (.png) to all files in the folder while keeping the original name, e.g. from NAME1
to NAME1.png
, NAME3
to NAME3.png
, NAME6
to NAME6.png
etc using R?
Install the
pathological
package and usereplace_extension
.With the
list.files
function you can retrieve the file names under a given path and with a given pattern. From them you can usepaste
to add your file extension and nextfile.rename
to rename the files. For instance: