Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10th September 2011, 03:05 PM
parpi Offline
Registered User
 
Join Date: Sep 2011
Posts: 5
linuxfirefox
Post Files & Folders

Hi, I have a folder that I keep my movies in. It contains individual folders with the movies (in .avi format)
e.g /MOVIES/bananas/Bananas.avi
I want to get rid of the individual folders and move the .avi files into one parent folder/directory, e.g /MOVIES
Is there a command I can use to move all the files (over 1000 movies) without having to cd into each individual directory?
Many thanks
Reply With Quote
  #2  
Old 10th September 2011, 03:26 PM
PatMcLJr's Avatar
PatMcLJr Offline
Registered User
 
Join Date: Apr 2005
Location: earth
Posts: 1,130
linuxopera
Re: Files & Folders

dunno,
maybe you could figure it out with mmv, multi-move
__________________
x--x--x
http://www.gnu.org/philosophy/free-sw.html
Freedom is never Free.
Pat Jr.
Reply With Quote
  #3  
Old 10th September 2011, 04:04 PM
Gareth Jones Offline
Official Gnome 3 Sales Rep. (and Adminstrator)
 
Join Date: Jul 2011
Location: Leamington Spa, UK
Age: 30
Posts: 1,689
linuxfirefox
Re: Files & Folders

If there is only one level of directories below MOVIES, then something like (in a terminal window):
Code:
cd /MOVIES
find -type f -exec mv {} . \;
find -type d -exec rmdir {} \;
Gareth

---------- Post added at 04:04 PM ---------- Previous post was at 04:01 PM ----------

P.S.: Before running that, you should stick "echo" between "-exec" and "mv"/"rmdir" and check that the output looks reasonable.
Reply With Quote
  #4  
Old 10th September 2011, 06:13 PM
parpi Offline
Registered User
 
Join Date: Sep 2011
Posts: 5
linuxfirefox
Re: Files & Folders

Thanks Gareth. I tried your code but everything went to trash. Maye I missed something? Doing a restore and will try again.
Reply With Quote
  #5  
Old 10th September 2011, 06:37 PM
Chilly Willy's Avatar
Chilly Willy Offline
Registered User
 
Join Date: Jul 2008
Posts: 1,235
linuxfedorafirefox
Re: Files & Folders

Not sure if LINUX will support the use of wild cards in this manner, but if it DOES, since the files all end in .avi that would work if something like *.avi works in LINUX. I'm not sure & wouldn't know off hand what the code would be, as I haven't had to try it yet.

You would have to start at the root parent of your movies & tell it to search the subfolders, & again, I'm not sure what that code would be or even if linux allow this. (It DOES work in the search, so it just may work here.)

Here is ONE approach, if you don't mind GUI...
Use the wild card in the search then cut / paste (move) from there.
__________________
Chilly Willy, Tux's little cousin...

By its very nature, Windows is a PANE!

Last edited by Chilly Willy; 10th September 2011 at 06:40 PM.
Reply With Quote
  #6  
Old 10th September 2011, 06:41 PM
flyingfsck Online
Registered User
 
Join Date: Aug 2010
Location: Al Ain, UAE
Posts: 1,046
linuxfirefox
Re: Files & Folders

The find command with the exec option is what you got to use, as explained above. Read the man page.

It is pretty easy if you read the man page and you have some idea of how a Bash terminal works.
Reply With Quote
  #7  
Old 10th September 2011, 07:05 PM
Chilly Willy's Avatar
Chilly Willy Offline
Registered User
 
Join Date: Jul 2008
Posts: 1,235
linuxfedorafirefox
Re: Files & Folders

One of these days I gotta come up with a reference method that works, for me, to keep all the different OS's straight that I have floating around in my head. (& with the medical memory problems I have, THAT doesn't help either.) & I DO need to get a better grasp on the linux CLI command (bash or whatever). But I hope what info I DID offer, helps, even if only in a small way.
__________________
Chilly Willy, Tux's little cousin...

By its very nature, Windows is a PANE!
Reply With Quote
  #8  
Old 10th September 2011, 07:14 PM
parpi Offline
Registered User
 
Join Date: Sep 2011
Posts: 5
linuxfirefox
Re: Files & Folders

Thanks Chilly
& Thanks Flyingfsck.
Everything is easy if you know the answer. I can read the man pages till I'm blue in the face but don't expect to find the exact answer to what I'm looking for. That's why I was hoping someone out there encountered this before and knew what to do.
Between looking after a small baby and studying for Accounting exams, I guess I was just looking for a shortcut
Reply With Quote
  #9  
Old 10th September 2011, 07:21 PM
stevea's Avatar
stevea Offline
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,298
linuxfedorafirefox
Re: Files & Folders

Quote:
Originally Posted by parpi View Post
Thanks Gareth. I tried your code but everything went to trash. Maye I missed something? Doing a restore and will try again.
Yes, Gareth's commands have an error - they don't specify the directory argument to 'find'


Here is a more specific version ....
find /MOVIE -type f -name '*.avi' -exec /bin/mv {} /MOVIE \;

*IF* you want to get rid of empty subdirectories then ...
find /MOVIE -type d -exec rmdir --ignore-fail-on-non-empty {} \;
__________________
None are more hopelessly enslaved than those who falsely believe they are free.
Johann Wolfgang von Goethe
Reply With Quote
  #10  
Old 10th September 2011, 07:28 PM
Chilly Willy's Avatar
Chilly Willy Offline
Registered User
 
Join Date: Jul 2008
Posts: 1,235
linuxfedorafirefox
Re: Files & Folders

Personally, in your case, I'd just take the GUI approach & open your source in one folder & destination in another & drag & drop, problem done!

I use both CLI & GUI & find usage for both. & I'll be the FIRST to say that there are times that one just won't work while the other one will. But in THIS case for what I foresee being a ONE TIME event (for now anyway) why fight it, unless this is a CLI only environment.

That is the main advantage I see of GUI over CLI, you don't need to know the underlying commands to use it. Then when you DO get the time (& I know how that can be) you can learn to do the CLI, & hopefully, at your leisure, which makes it more pleasant.
__________________
Chilly Willy, Tux's little cousin...

By its very nature, Windows is a PANE!

Last edited by Chilly Willy; 10th September 2011 at 07:31 PM.
Reply With Quote
  #11  
Old 11th September 2011, 12:11 AM
parpi Offline
Registered User
 
Join Date: Sep 2011
Posts: 5
linuxfirefox
Re: Files & Folders

Thanks Stevea. I tried again and lost everything. Will have to do it the long GUI way.

Many thanks to all
Reply With Quote
  #12  
Old 11th September 2011, 06:45 PM
Gareth Jones Offline
Official Gnome 3 Sales Rep. (and Adminstrator)
 
Join Date: Jul 2011
Location: Leamington Spa, UK
Age: 30
Posts: 1,689
linuxfirefox
Re: Files & Folders

Quote:
Originally Posted by stevea View Post
Yes, Gareth's commands have an error - they don't specify the directory argument to 'find'

Here is a more specific version ....
find /MOVIE -type f -name '*.avi' -exec /bin/mv {} /MOVIE \;
I'm a bit rusty on find usage, but I'm pretty sure it defaults to the working directory if you don't specify one, and runs -exec commands in the working directory too (as opposed to -execdir, which runs commands in the directory containing the file).

Gareth

---------- Post added at 06:32 PM ---------- Previous post was at 06:20 PM ----------

Quote:
Originally Posted by parpi View Post
Thanks Gareth. I tried your code but everything went to trash. Maye I missed something? Doing a restore and will try again.
By everything do you mean the videos or the whole system? Which command caused the files to be deleted? Assuming you're running in the /MOVIES directory as an unprivileged user, they should be fairly safe. "mv" only moves files, and "rmdir" only removes empty directories.

I'll just create a dummy directory on my system to check everything's sane, with this hangover all bets are off...

Gareth

---------- Post added at 06:45 PM ---------- Previous post was at 06:32 PM ----------

My original commands work fine on my machine, sorry.

The "find ... rmdir ..." command will give errors about "." (the /MOVIES directory), but won't delete it, and errors about the directories not existing after deleting them (find tries to search inside the directories that it's already run rmdir on, unless you add the -depth option). Did you see any other odd messages?

Make sure you run the "cd /MOVIES" command first, and run the commands from an unprivileged shell (not Alt+F2 or a run dialog as these will ignore the cd command).

Gareth
Reply With Quote
  #13  
Old 11th September 2011, 07:21 PM
jamielinux Offline
Registered User
 
Join Date: Jun 2011
Posts: 64
linuxfirefox
Re: Files & Folders

Quote:
Originally Posted by stevea View Post
Yes, Gareth's commands have an error - they don't specify the directory argument to 'find'

Here is a more specific version ....
find /MOVIE -type f -name '*.avi' -exec /bin/mv {} /MOVIE \;
Always quote the braces, like so:
Code:
find /MOVIE -type f -iname '*.avi' -exec /bin/mv '{}' /MOVIE \;
From the man page for find:
Quote:
Notice that the braces are enclosed in single quote marks to protect them from interpretation as shell script punctuation.
Reply With Quote
  #14  
Old 11th September 2011, 09:21 PM
marriedto51 Offline
Registered User
 
Join Date: Jul 2009
Location: England, UK
Posts: 821
linuxfirefox
Re: Files & Folders

If there is just one level between MOVIES and the actual .avi files, then you should be able to do the moving with just
Code:
cd MOVIES && mv */*.avi .
(Apologies if I've mis-read what you wanted; this just looked easier than the find commands.)
Reply With Quote
  #15  
Old 11th September 2011, 09:42 PM
jamielinux Offline
Registered User
 
Join Date: Jun 2011
Posts: 64
linuxfirefox
Re: Files & Folders

Hehe that would work too

Whatever the method, I would suggest using "mv -v -n".

"-v" so you can see what is happening.
"-n" so that you won't overwrite a file that happens to have the same name.
Reply With Quote
Reply

Tags
files, folders

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving files between folders Mazate Using Fedora 1 14th May 2011 09:59 AM
How to maintain files and folders for changes duni Using Fedora 0 27th April 2007 10:53 AM
Copying files/folders to CD hmclaurin Guides & Solutions (No Questions) 7 18th April 2007 02:23 PM
KDE Desktop Files/Folders Not there - FC4 petros429 Using Fedora 3 29th December 2005 03:12 AM
New files and folders not showing up dndfan Using Fedora 1 5th November 2005 04:57 PM


Current GMT-time: 18:07 (Saturday, 18-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat