Skip to main content

I am using a string concatenator to
write batch files for me.

I am entering a windows path in the string concatenator (see
below).

%SendKeys% "E:\FME\Development Work\Timesheet
Analysis\Output\@Value(HomeTeamFP)\@Value(Name) @Value(DateFrom) to @Value(DateTo){ENTER}"

But the string it writes out is 

%SendKeys% "E:\FME\Development Work\Timesheet
Analysis/Output\RUR370\Amy Hutsby 2018-01-01 to 2018-01-31{ENTER}"

I.e. it changes to ...Analysis\Output... to
...Analysis/Output... 

This then leads the batchfile to fail to work. 

It has happened several times and I dont know what is
causing it or how to fix it. 

Any ideas from anyone? 

Thanks

Hi Seb, An absolute hack is to follow it with a StringReplacer that swaps / to \\, it's a hack that solves the problem short term. Slashes are definitely a challenge frequently and its because they are a bit "special" especially as they sometimes need to be reversed for Linux. I suspect someone else has a much more slid explanation of why this might be happening though.


Hi Seb, An absolute hack is to follow it with a StringReplacer that swaps / to \\, it's a hack that solves the problem short term. Slashes are definitely a challenge frequently and its because they are a bit "special" especially as they sometimes need to be reversed for Linux. I suspect someone else has a much more slid explanation of why this might be happening though.

Thanks Dave. I hadnt thought of that. Good short term fix.

 

Cheers

 

 

 


I tend not to use string transformers as I use python callers

HomeTeamFP = feature.getAttribute('HomeTeamFP')
DateFrom= feature.getAttribute('DateFrom')
DateTo= feature.getAttribute('DateTo')

#or if parameter 
Name = FME_MacroValuesÂ'Name']

fullstring = '%SendKeys% "E:\FME\Development Work\TimesheetAnalysis\Output\{}\{} {} to {}{{ENTER}}"'.format(HomeTeamFP,Name,DateFrom,DateFrom)

feature.setAttribute('BatFile',fullstring)

could in fact write the bat files in python too


Reply