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

10th September 2011, 03:05 PM
|
|
Registered User
|
|
Join Date: Sep 2011
Posts: 5

|
|
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
|

10th September 2011, 03:26 PM
|
 |
Registered User
|
|
Join Date: Apr 2005
Location: earth
Posts: 1,130

|
|
|
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.
|

10th September 2011, 04:04 PM
|
|
Official Gnome 3 Sales Rep. (and Adminstrator)
|
|
Join Date: Jul 2011
Location: Leamington Spa, UK
Age: 30
Posts: 1,689

|
|
|
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.
|

10th September 2011, 06:13 PM
|
|
Registered User
|
|
Join Date: Sep 2011
Posts: 5

|
|
|
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.
|

10th September 2011, 06:37 PM
|
 |
Registered User
|
|
Join Date: Jul 2008
Posts: 1,235

|
|
|
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.
|

10th September 2011, 06:41 PM
|
|
Registered User
|
|
Join Date: Aug 2010
Location: Al Ain, UAE
Posts: 1,046

|
|
|
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.
|

10th September 2011, 07:05 PM
|
 |
Registered User
|
|
Join Date: Jul 2008
Posts: 1,235

|
|
|
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!
|

10th September 2011, 07:14 PM
|
|
Registered User
|
|
Join Date: Sep 2011
Posts: 5

|
|
|
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
|

10th September 2011, 07:21 PM
|
 |
Registered User
|
|
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,298

|
|
|
Re: Files & Folders
Quote:
Originally Posted by parpi
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
|

10th September 2011, 07:28 PM
|
 |
Registered User
|
|
Join Date: Jul 2008
Posts: 1,235

|
|
|
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.
|

11th September 2011, 12:11 AM
|
|
Registered User
|
|
Join Date: Sep 2011
Posts: 5

|
|
|
Re: Files & Folders
Thanks Stevea. I tried again and lost everything. Will have to do it the long GUI way.
Many thanks to all
|

11th September 2011, 06:45 PM
|
|
Official Gnome 3 Sales Rep. (and Adminstrator)
|
|
Join Date: Jul 2011
Location: Leamington Spa, UK
Age: 30
Posts: 1,689

|
|
|
Re: Files & Folders
Quote:
Originally Posted by stevea
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
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
|

11th September 2011, 07:21 PM
|
|
Registered User
|
|
Join Date: Jun 2011
Posts: 64

|
|
|
Re: Files & Folders
Quote:
Originally Posted by stevea
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.
|
|

11th September 2011, 09:21 PM
|
|
Registered User
|
|
Join Date: Jul 2009
Location: England, UK
Posts: 821

|
|
|
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.)
|

11th September 2011, 09:42 PM
|
|
Registered User
|
|
Join Date: Jun 2011
Posts: 64

|
|
|
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.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Current GMT-time: 18:07 (Saturday, 18-05-2013)
|
|
 |
 |
 |
 |
|
|