I need to copy files from one directory to another without copying any sub-directories. The number and name of sub-directories is dynamic so I cannot "--exclude" specific directories or use the "-r" option. How can I exclude all sub-directories?
CODE1:
cp '/media/lm1/My Passport/OneDrive/Music/Yes/*.*' '/home/lm1/Music/Archive'
RESULT1:
p: cannot stat '/media/lm1/My Passport/OneDrive/Music/Yes/*.*': No such file or directory
CODE2:
cp '/media/lm1/My Passport/OneDrive/Music/Yes/*' '/home/lm1/Music/Archive'
RESULT2:
p: cannot stat '/media/lm1/My Passport/OneDrive/Music/Yes/*': No such file or directory
CODE3:
cp '/media/lm1/My Passport/OneDrive/Music/Yes' '/home/lm1/Music/Archive'
RESULT3:
cp: -r not specified; omitting directory '/media/lm1/My Passport/OneDrive/Music/Yes'
Glob patterns (the wildcard *.*
) don't work within quotes, but you can move the glob outside the quotes like so:
cp '/media/lm1/My Passport/OneDrive/Music/Yes/'*.* '/home/lm1/Music/Archive'