MATLAB: Sprintf – Linux OK but Windows Warning: Escaped character ‘\.’ is not valid. See ‘doc sprintf’ for supported special characters.

escape characterMATLAB and Simulink Student Suitesprintf

I was using the following code inside a for loop to loop through multiple data folders and specify the folder as basically 'main\1', 'main\2', etc. on Ubuntu 16.04 Linux:
currentfolder = sprintf([DICOMdatafolder,'\%d'],loopPt);
It worked fine. In Windows 10, however:
Warning: Escaped character '\.' is not valid. See 'doc sprintf' for supported special characters.
Removing the \ causes the same warning, and so does the following:
currentfolder = sprintf(fullfile(DICOMdatafolder,'%d'),loopPt);
so I don't know what's wrong. Looking at the documentation, %d appears correct, and I don't understand what it is reading as an escape character. (I'm not sure what an escape character is, either: I thought it was used for syntax in a regular expression, but I didn't that was the case here.)
What is causing this warning and how do I resolve it to properly specify the folder as main/1, main/2, etc while looping through folders?
Below is a larger excerpt of the code:
DICOMdatafolder = fullfile('..','..','..','data','DICOMfiles');
NoPtfolders = CountNumberofFolders(DICOMdatafolder);
for loopPt = 1:NoPtfolders
currentfolder = sprintf([DICOMdatafolder,'%d'],loopPt);

Best Answer

Use sprintf('%s%d',DICOMdatafolder,loopPt)
Remember that the path separator for windows is \ so your fullfile call is going to contain ..\..\ in the output but on Linux would instead have ../..
When you use the result in the first parameter of sprintf you are asking it to use those \ characters in the format specification.