LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 03-04-2010, 06:42 AM   #1
anurupr
Member
 
Registered: Mar 2010
Posts: 71

Rep: Reputation: 16
i need to copy files from one folder to another folder using shell


i need to copy files from a folder called output files to another folder called running but im not able to do it
i always get a stat error
can anyone please help me?
 
Old 03-04-2010, 06:43 AM   #2
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,598
Blog Entries: 29

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
Would you be kind enough to post the exact error message here.
 
Old 03-04-2010, 06:46 AM   #3
anurupr
Member
 
Registered: Mar 2010
Posts: 71

Original Poster
Rep: Reputation: 16
cp: cannot stat `text2sound': No such file or directory
cp: cannot stat `/output files/': No such file or directory

this is the error that came when i gave the command

sudo cp text2sound /output\ files/ running/

P.S. text2sound is an output file
 
Old 03-04-2010, 06:49 AM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
Both directories must exist already.

You need to use the full path if you are not running the command from inside one of those folders. And using directories with spaces in the names is silly. You have to use quotes around the directory name.

assuming those directories are both in /home/user

then

Code:
cp "/home/user/output files/*.*" /home/user/running/

Last edited by smoker; 03-04-2010 at 06:50 AM.
 
Old 03-04-2010, 06:50 AM   #5
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,598
Blog Entries: 29

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
Quote:
Originally Posted by anurupr
this is the error that came when i gave the command
Now do
Code:
ls -l
from the directory where 'text2sound' file is located and post the output here:

EDIT
as well as

from the directory where 'running' file is located and post the output here:

Last edited by TheIndependentAquarius; 03-04-2010 at 07:12 AM.
 
Old 03-04-2010, 07:03 AM   #6
anurupr
Member
 
Registered: Mar 2010
Posts: 71

Original Poster
Rep: Reputation: 16
i tried the code u told me but it didnt work

this is the error

cp: cannot stat `/home/anurupr/Desktop/text2soundconversion/outputfiles/*.*': No such file or directory

i tried the following command
sudo cp "/home/anurupr/Desktop/text2soundconversion/outputfiles/*.*" /home/anurupr/Desktop/text2soundconversion/running/
 
Old 03-04-2010, 07:27 AM   #7
tommcd
Senior Member
 
Registered: Jun 2006
Location: Philadelphia PA USA
Distribution: Lubuntu, Slackware
Posts: 2,221

Rep: Reputation: 285Reputation: 285Reputation: 285
As Smoker said, don't use directory names with spaces in them. Can you rename the "output files" directory to output-files, or something like that?
From the directory where "output files" is located run:
Code:
 mv output\ files/ output-files
Or just right-click on "output files" and choose rename if you are running a graphical desktop and not just a shell.
And what is the full file path to the files you want to copy? And what is the full file path to the directory that you want to copy them to?
Can you just move "output files" and "running" to your home directory to make this easier?

Last edited by tommcd; 03-04-2010 at 07:29 AM.
 
Old 03-04-2010, 07:31 AM   #8
anurupr
Member
 
Registered: Mar 2010
Posts: 71

Original Poster
Rep: Reputation: 16
well that would be easier but this is part of my application so i need to move it automatically when i run the script . i suppose there isnt any otherway to copy
 
Old 03-04-2010, 07:35 AM   #9
tommcd
Senior Member
 
Registered: Jun 2006
Location: Philadelphia PA USA
Distribution: Lubuntu, Slackware
Posts: 2,221

Rep: Reputation: 285Reputation: 285Reputation: 285
Quote:
Originally Posted by anurupr View Post
well that would be easier but this is part of my application so i need to move it automatically when i run the script . i suppose there isnt any otherway to copy
I don't understand what that means.
Application for what? And what script?
 
Old 03-04-2010, 07:50 AM   #10
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
Quote:
Originally Posted by anurupr View Post
i tried the code u told me but it didnt work

this is the error

cp: cannot stat `/home/anurupr/Desktop/text2soundconversion/outputfiles/*.*': No such file or directory

i tried the following command
sudo cp "/home/anurupr/Desktop/text2soundconversion/outputfiles/*.*" /home/anurupr/Desktop/text2soundconversion/running/
I thought you said it was called "output files" not outputfiles ?
And you don't need sudo if it's in your own home directory.

Last edited by smoker; 03-04-2010 at 07:52 AM.
 
Old 03-04-2010, 07:53 AM   #11
anurupr
Member
 
Registered: Mar 2010
Posts: 71

Original Poster
Rep: Reputation: 16
well my application needs to convert text to sound and sound back to text , i just want a script that will handle the necessary files ..and i changed the name from "output files" to outputfiles
 
Old 03-04-2010, 07:55 AM   #12
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
what is the output from
ls -l /home/anurupr/Desktop/text2soundconversion
 
Old 03-04-2010, 07:57 AM   #13
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
What is "*.*"?

If that's what I think it means in DOS/Windows, you should actually be using just "*", because Unix does not have file extensions.

Also, do not put spaces in filenames because bash will treat them like separate arguments.
 
Old 03-04-2010, 08:01 AM   #14
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
Quote:
Originally Posted by MTK358 View Post
What is "*.*"?

If that's what I think it means in DOS/Windows, you should actually be using just "*", because Unix does not have file extensions.

Also, do not put spaces in filenames because bash will treat them like separate arguments.
That's odd, I have plenty of file.png and file.pl and file.rc

But considering it can't find the directory I don't think thats a problem.
If there were no files with an extension it wouldn't do anything, but it wouldn't return a stat error.

Last edited by smoker; 03-04-2010 at 08:02 AM.
 
Old 03-04-2010, 08:06 AM   #15
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Quote:
Originally Posted by smoker View Post
That's odd, I have plenty of file.png and file.pl and file.rc

But considering it can't find the directory I don't think thats a problem.
If there were no files with an extension it wouldn't do anything, but it wouldn't return a stat error.
I am not saying that "extensions" are not used, I am saying that the Unix operating system itself does not have such a concept (they are just used for user convenience, and some programs may require them), and that unlike Windows, Unix filenames are allowed not to have an extension, so *.* will not match all files.

I once tried to make a filename without an extension in Windows, but it still showed to have a ".txt" extension in the DOS prompt even though it didn't show in explorer (I had it set to show extensions)!

You won't find such nonsense in Linux.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script to search and copy jpg to Another Folder. ajayan Linux - Newbie 9 09-23-2012 06:46 AM
want to copy an inode folder from acdrom to a home directory (folder). nhbob Linux - Newbie 8 12-20-2009 11:12 AM
How to copy files into ReadOnly folder? AndreLi Linux - Software 2 11-19-2009 07:39 AM
copy files into /usr folder knobby67 Linux - Software 4 10-04-2009 01:19 PM
To copy files from a CD to a folder on your system Gins Linux - General 20 10-30-2006 12:53 PM


All times are GMT -5. The time now is 02:36 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration