Dear all, Is there a good way of doing the following conversion:
[YYYY]-[MM]-[DD] [Time] [Day] [Name][Integer].[Extention] to become C:\test\[Name]\[YYYY]-[MM]-[DD] [Time] [Day]\[YYYY]-[MM]-[DD] [Time] [Day] [Name][Integer].[Extention] i.e. these 2009-04-10 1400 Fri Foo1.txt 2009-04-10 1400 Fri Universities2.txt 2009-04-10 1400 Fri Hitchhikers Guide To The Galaxy42.txt will become C:\test\Foo\2009-04-10 1400 Fri Foo1.txt C:\test\Universities\2009-04-10 1400 Fri Universities2.txt C:\test\Hitchhikers Guide To The Galaxy\2009-04-10 1400 Fri Hitchhikers Guide To The Galaxy42.txt My main issue is the conversion for 'Hitchkikers Guide To The Galaxy54' because of the spaces in the Name. So far this is what i have: > txt <- '2009-04-10 1400 Fri Universities1.txt' > step1 <- unlist(strsplit(txt, '\\.')) > step2 <- unlist(strsplit(step1[1], ' ')) > Name <- gsub('[0-9]',replacement='', step2[4]) > step3 <- paste(step2[1], step2[2], step2[3], sep=' ') > paste('C:\\test\\', Name, '\\', step3, '\\', txt, sep='' ) [1] "C:\\test\\Universities\\2009-04-10 1400 Fri\\2009-04-10 1400 Fri Universities1.txt" Cheers, Tony Breyal ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.