LinuxQuestions.org
Help answer threads with 0 replies.
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
  Search this Thread
Old 06-20-2015, 04:32 PM   #1
Charliesrch
LQ Newbie
 
Registered: May 2015
Location: St. Petersburg, FL
Distribution: Ubuntu 14.04.2
Posts: 29

Rep: Reputation: Disabled
Command Syntax to move or copy files to a new folder


I have created a couple of new folders that reside in the file cabinet of my Ubuntu 14.04.2 LTS install. I have not been able to move or copy loose files from the Documents directory using the Terminal (the folders were created in the Terminal and they show in the File Cabinet). I get responses from a "mv" or "cp" line command such as "no such file exists" or "directory", etc. Is there a proper syntax for naming a file? The files I have tried to move or copy were created in LibreOffice Calc or .pdf downloaded files. I can drag-and drop from the desktop but I want to learn how to use the Terminal extensively.
 
Old 06-20-2015, 05:21 PM   #2
JeremyBoden
Senior Member
 
Registered: Nov 2011
Distribution: Debian
Posts: 1,041

Rep: Reputation: 206Reputation: 206Reputation: 206
If the file is not in your current directory, you will need to give an absolute or relative path to the file.
e.g.
Code:
mv /home/username/fromfilename tofilename
will rename a file.
Code:
mv ~/fromfilename tofilename
Is slightly easier. I suggest you read the output of
Code:
man mv
 
1 members found this post helpful.
Old 06-20-2015, 06:31 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,396

Rep: Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017Reputation: 2017
Tab completion is your friend. Type the first few characters of the file and hit tab. If it doesn't fill in the rest of the name for you, hit tab again. If there are multiple files with the same first few characters, it will print them out. If it doesn't do anything, then there is no file in that directory that begins with those characters. I can't even remember the last time I typed in an entire filename manually, it's just asking for stupid typo errors and you second guessing if you spelled it correctly.
 
1 members found this post helpful.
Old 06-20-2015, 06:37 PM   #4
Billy@2015
LQ Newbie
 
Registered: Jun 2015
Posts: 8

Rep: Reputation: Disabled
@ Charliesrch

If your file(s) resides in another location. You can type the path like so. An Example:

Code:
mv ~/Documents/filename.txt ~/Documents/newfilename.txt
Or cd to the Documents folder and then use mv or cp

Code:
cd ~/Documents

mv filename.txt newfilename.txt
Remember, mv works in two ways. It will move a file(s) to another location or rename the file(s).



Also, if your files have special characters, you'd need to use an escape character like '\' or wrap the filename in quotes.



this\ is\ a\ sample\ file.txt

"this is a sample file.txt"

In these two examples, the space is the special character.

You can also use TAB completion to fill the rest of the filename. Just type the first few letters of the filename and press TAB. If it's the only file that begins with those letters, TAB completion will fill the rest.If not, type the next letter and press TAB. Keep repeating until TAB completion fill the filename completely.

TAB completion can work on files, directories and directory paths.

Last edited by Billy@2015; 06-20-2015 at 07:18 PM.
 
2 members found this post helpful.
Old 06-21-2015, 03:52 AM   #5
Charliesrch
LQ Newbie
 
Registered: May 2015
Location: St. Petersburg, FL
Distribution: Ubuntu 14.04.2
Posts: 29

Original Poster
Rep: Reputation: Disabled
Many THANKS ! As an extremely new newbie, sometimes I need some clarification such as these great examples and advice. The man pages - and Konqueror are helpful with my study and practice, but a 'helping hand' performs miracles when I hit a snag.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to move or copy files present between two dates to another path folder. ankitpandey Linux - General 22 02-06-2012 01:21 AM
[SOLVED] Using terminal command -Find files in a folder and copy them to a different folder j-jock Linux - General 4 11-28-2011 02:20 AM
Special copy command syntax davcefai Linux - General 4 08-13-2011 11:19 PM
Creating a script to move or copy files into multiple directories below the files matthes138 Linux - Newbie 5 08-25-2009 04:57 PM
How to automatically move files from one folder into another folder? xmrkite Linux - Software 6 11-05-2006 10:39 AM


All times are GMT -5. The time now is 07:29 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration