You are not logged in.

#1 2011-03-08 19:40:41

Convergence
Member
Registered: 2005-07-02
Posts: 377

Need a command to help sort out mess [solved]

I recently ran photorec on an old drive.  It managed to recover a lot of files, but they are in a large series of directories that do not correspond to the original directory tree.  It is going to take a while to sort the mess out, but it would be beneficial to sort these files by filetype.  I was never a bash guru, but at one point I'm pretty sure I wouldn't have had a problem with this!

So let me clarify:  There is a directory called ~/backup.  This directory contains many subdirectories (only one deep) that have files of all types, txt, jpg, etc...  I would like to create a directory called ~/jpg and use a command to search all subdirs in ~/backup to mv or cp all files of type jpg to that dir.  This command would probably involve "find ." with a pipe to mv or something, but I can't seem to figure it out on my own right now.

Thanks in advance

Last edited by Convergence (2011-03-08 20:26:20)


It's a very deadly weapon to know what you're doing
---  William Murderface

Offline

#2 2011-03-08 19:53:15

whatshisname
Member
Registered: 2010-04-24
Posts: 163

Re: Need a command to help sort out mess [solved]

I'd copy first:

find ~/backup -name "*.jpg" -exec cp {} ~/jpg \;
and
find ~/backup -name "*.JPG" -exec cp {} ~/jpg \;

Note: This will overwrite all files of the same name.

Offline

#3 2011-03-08 20:23:49

Convergence
Member
Registered: 2005-07-02
Posts: 377

Re: Need a command to help sort out mess [solved]

that was perfect.  thank you.


It's a very deadly weapon to know what you're doing
---  William Murderface

Offline

Board footer

Powered by FluxBB