LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   i need to copy files from one folder to another folder using shell (http://www.linuxquestions.org/questions/linux-newbie-8/i-need-to-copy-files-from-one-folder-to-another-folder-using-shell-793129/)

anurupr 03-04-2010 07:42 AM

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?

TheIndependentAquarius 03-04-2010 07:43 AM

Would you be kind enough to post the exact error message here.

anurupr 03-04-2010 07:46 AM

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

smoker 03-04-2010 07:49 AM

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/

TheIndependentAquarius 03-04-2010 07:50 AM

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:

anurupr 03-04-2010 08:03 AM

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/

tommcd 03-04-2010 08:27 AM

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?

anurupr 03-04-2010 08:31 AM

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

tommcd 03-04-2010 08:35 AM

Quote:

Originally Posted by anurupr (Post 3885427)
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?

smoker 03-04-2010 08:50 AM

Quote:

Originally Posted by anurupr (Post 3885381)
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.

anurupr 03-04-2010 08:53 AM

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

smoker 03-04-2010 08:55 AM

what is the output from
ls -l /home/anurupr/Desktop/text2soundconversion

MTK358 03-04-2010 08:57 AM

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.

smoker 03-04-2010 09:01 AM

Quote:

Originally Posted by MTK358 (Post 3885463)
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.

MTK358 03-04-2010 09:06 AM

Quote:

Originally Posted by smoker (Post 3885469)
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.


All times are GMT -5. The time now is 12:34 PM.