Passing Filename Arguments in Execute Task Process
-
Friday, November 30, 2012 8:52 AM
Hi All,
Having an issue trying to pass a filename as an argument to a batch file from a Execute Task Process. The filename passes fine if the filename contains no spaces but as soon as a space is invloved it truncates the filename.
EG:
Filename1.txt would pass fine and be echoed out to a test file by my simple batch below:
echo %1 > file.txt
However, if my filename is like "Filename1 with spaces.txt" only Filename1 is getting output.
Any ideas how to cater for the spaces?
Many Thanks,
Slash.
All Replies
-
Friday, November 30, 2012 9:21 AM
I am sure of the dos commands but if you put the file name in double quotes might help "File with spaces.txt"
Regards,Eshwar -Please vote as helpful or mark as answer, if it helps
-
Friday, November 30, 2012 10:03 AM
Hi - thanks for the reply.
I'm not 100% sure of what you mean? In my execute task process i have expression --> Arguments --> @[User::Filename]
In my batch file i have:
echo %1 > file.txt
Now if i echo %1 and then %2 i get the second part of the filename. It's as though its been treated as two seperate arguments because of the space in the filename.
Slash.
-
Tuesday, December 04, 2012 8:38 AM
Any one got any ideas on this?
The only way i've gotten this to work is by concating %1 to %9 together and then using a trim in a following script to remove any spaces that are not required.
This would only work if my filename had upto 9 spaces so i'm looking for a more robust solution?
Thanks all,
Slash.
-
Tuesday, December 04, 2012 9:24 AM
Try the following expression:
"\"" + @[User::Filename] + "\""
This adds the quotes that dos uses to treat the whole item as one parameter.
Russel Loski, MCT, MCITP Business Intelligence Developer and Database Developer 2008 Twitter: @sqlmovers; blog: www.sqlmovers.com
-
Friday, December 07, 2012 9:42 AM
Thanks Russ,
I'll give this a try and let you know.
Slash.

