0

I have list of files which I need to copy from one location to another

Input File: c:/Unknown/Absolute.txt c:/Unknown/Absolute With Space.txt

If I try a script to read the input file and do a cp to a destination directory it fails ,The file Absolute.txt gets copied like I wanted however the Absolute With Space.txt doesn't . How would I achieve copying the file names with space ??

david xavier
  • 71
  • 1
  • 5

2 Answers2

4

Space is used as separation character, if you don't want that, use "quotes" or escape the spaces with \_ (where _ is a space). So this should both work:

cp "c:/Unknown/Absolute.txt" "c:/Unknown/Absolute With Space.txt"
cp c:/Unknown/Absolute.txt c:/Unknown/Absolute\ With\ Space.txt
pfnuesel
  • 14,093
  • 14
  • 58
  • 71
-1

In general, if you are dealing with variables instead of direct locations use this code

source="c:/Unknown/Absolute.txt"
destination="c:/Unknown/Absolute With Space.txt"

if(' ' not in destination):
    !copy $source $destination
else:
    !copy $source "$destination"

This works in Windows OS

Kirushikesh
  • 578
  • 5
  • 8