system command to copy a file to a path with a space in it
Bruce Easton
bruce at stn.com
Wed Mar 25 09:00:18 PDT 2015
Richard - yes. But that's not a good example of such as ".../cp" is the
end of the *nix copy command, and "/reports.." is the start of its first
argument.
Bruce
On 3/25/15 11:41 AM, Richard Kreiss wrote:
> Just for a clarification, can a directory name contain a space?
>
> In this example there seems to be a space after /cp /but before Reports.
>
> Richard
> Sent from my iPhone
>
>> On Mar 25, 2015, at 11:32 AM, Kenneth Brody <kenbrody at spamcop.net> wrote:
>>
>>> On 3/25/2015 10:36 AM, Josh Reader wrote:
>>> Thanks to all who replied! Either of the following methods worked
>>> perfectly:
>>>
>>> Option 1
>>>
>>> -----------
>>>
>>> cm = "/bin/cp /reports/state.pdf \"/reports/Josh Reader/josh.pdf\""
>>> system cm
>>>
>>> Option 2
>>>
>>> ----------
>>>
>>> system "/bin/cp /reports/state.pdf '/reports/Josh Reader/josh.pdf'"
>> Note, of course, that both versions can be a single command. (No need to create the temporary "cm" variable in the first version.) Assuming that the filenames are hard-coded, that is.
>>
>> The main thing is that the filename with spaces (or any "special characters", such as semi-colons, ampersands, and so on) must be within quotes in order for the shell to treat it as a single argument. Quotes can be used in all cases, even if there are no "special characters" in the filename. For example, this will work for any filename that doesn't contain apostrophes (aka "single quotes"):
>>
>> system "/bin/cp '" & SourceFilename & "' '" & DestFilename & "'"
>>
>>
>> --
>> Kenneth Brody
>> _______________________________________________
>> Filepro-list mailing list
>> Filepro-list at lists.celestial.com
>> Subscribe/Unsubscribe/Subscription Changes
>> http://mailman.celestial.com/mailman/listinfo/filepro-list
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> Subscribe/Unsubscribe/Subscription Changes
> http://mailman.celestial.com/mailman/listinfo/filepro-list
>
More information about the Filepro-list
mailing list