tip: deleting a subset of files

2 views
Skip to first unread message

Lauren Hodgson

unread,
Aug 30, 2012, 10:24:14 PM8/30/12
to tropi...@googlegroups.com
Today I wanted to keep a subset of species map images I'd produced
from a folder, and delete the rest. The files were named as such:

Genus_species.png

My species names were in the format: Genus_species


unwanted.species = #a subset of species that you want to delete the files for
unwanted.files=paste(unwanted.species,'.png',sep='') #format species
names as image file names as they appear in your folder ie.
Genus_species.png
setwd('/home/jc148322/folder_with_files/'') #set the directory
unlink(unwanted.files) #delete the subset of files from the directory.
Reply all
Reply to author
Forward
0 new messages