How to: Use filenames longer than 255 characters on Windows
The maximum number of symbols in a Windows pathname is 256, including file separators '/' or '\', but excluding the drive letter, and initial file separator (e.g. 'C:/'), and the string terminator ('\0'), cf. MSDN - Naming a File or Directory. In R, the limit is one symbol less, i.e. 255.
Here is an example of a very long pathname:
# Working directory: pwd <- getwd() print(pwd) ##  "C:/Users/AromaUser/Project_2010/TCGA,GBM,analysis/redundancyTests/" # Result directory: path <- "cbsData/broad.mit.edu_GBM.Genome_Wide_SNP_22.214.171.124,pairs/GenomeWideSNP_6/" # Filename filename <- "TCGA-06-0208,01A,01D-0236-01,ratios,ref=TCGA-06-0208,10A,01D-0237-01,log2ratio,total,chr09,dbc39899be02529b41df0a9416537f0a.xdr" # Complete pathname pathname <- file.path(pwd, path, filename) print(nchar(pathname)) ##  267
This limitation typically reveals itself as "file" errors. One example
"In gzfile(file, "wb") : cannot open compressed file '<long pathname>',
probable reason 'No such file or directory'. Another
"Error in dirname(pathname) : file name conversion problem".
- Use a working directory that is higher up in the directory structure, e.g. instead of 'C:/way/too/long/path/' use 'C:/short/path/'.
- The [Windows/MS-DOS] console
'subst' utility makes a drive
letter to any Windows directory, e.g.
subst Y: 'C:/Documents and Settings/JohnDoe/Documents/My Research/Projects/aroma.affymetrix/ProjectA/'.
- The following R.utils solution maps the current working directory to 'Y:' (using the above internally) and updates the working directory
to be 'Y:/':