Re: Shell guru needed.
Try any unix primer or man find or find /my/unorganized/dir -name '*.pdf' -type f -exec echo mv {} /my/pdfs \; and pray that you do not have files with identical names. On Thu, 2 Jan 2003, mike wrote: Hey guys. heres the skinny. I have a huge library and i want to organize it. I want find to go through recursively, and move any pdf files it finds to a certain directory. I need an example piece of script on how i would confront this. It will save me hours if not days so thanks in advance. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Shell guru needed.
On Thu, Jan 02, 2003 at 08:03:37PM -0500 mike [EMAIL PROTECTED] wrote: Hey guys. heres the skinny. I have a huge library and i want to organize it. I want find to go through recursively, and move any pdf files it finds to a certain directory. I need an example piece of script on how i would confront this. It will save me hours if not days so thanks in advance. Can't believe no one has used xargs yet... find /path/to/messydir -name '*.pdf' -type f | xargs -I % mv \ /path/to/messydir/% /path/to/newdir/% -- David S. Jackson[EMAIL PROTECTED] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Don't worry about the world coming to an end today. It's already tomorrow in Australia. -- Charles Schulz To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Shell guru needed.
On Thu, Jan 02, 2003 at 08:03:37PM -0500, mike wrote: Hey guys. heres the skinny. I have a huge library and i want to organize it. I want find to go through recursively, and move any pdf files it finds to a certain directory. I need an example piece of script on how i would confront this. It will save me hours if not days so thanks in advance. I'm no shell guru but how about something like find ./yourdirectory -name *pdf -exec mv {} ./newdirectory \; you may have to play with the syntax a little but wouldn't this do it? -- David Bear College of Public Programs/ASU Mail Code 0803 To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Shell guru needed.(xargs question)
Could you please give another realworld example of using xargs and your definition of it. I had a glance through man xargs, but I enjoy input from humans that use it as well. :) Thanks. - Original Message - From: David S. Jackson [EMAIL PROTECTED] To: mike [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 03, 2003 10:25 AM Subject: Re: Shell guru needed. On Thu, Jan 02, 2003 at 08:03:37PM -0500 mike [EMAIL PROTECTED] wrote: Hey guys. heres the skinny. I have a huge library and i want to organize it. I want find to go through recursively, and move any pdf files it finds to a certain directory. I need an example piece of script on how i would confront this. It will save me hours if not days so thanks in advance. Can't believe no one has used xargs yet... find /path/to/messydir -name '*.pdf' -type f | xargs -I % mv \ /path/to/messydir/% /path/to/newdir/% -- David S. Jackson[EMAIL PROTECTED] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Don't worry about the world coming to an end today. It's already tomorrow in Australia. -- Charles Schulz To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Shell guru needed.(xargs question)
On Fri, Jan 03, 2003 at 10:55:09AM -0500 Danny [EMAIL PROTECTED] wrote: Could you please give another realworld example of using xargs and your definition of it. I had a glance through man xargs, but I enjoy input from humans that use it as well. :) Xargs is pretty neat. You have to remember that there are different implementations of it, too, so xargs on Linux would probably be different than xargs on *BSD (it always is different in my experience). The differences would mainly be in switches and default behavior. I use xargs with lots of different utilities, just depending on what I need to do with whatever files I'm catching. For example, let's say I wanted to rename some files: locate *.PDF | xargs -I % mv % `basename % .PDF`.pdf It's handy if you have a bunch of files in one directory that you want to check somehow: ls *.{jpg,gif} | xargs -J % file % | grep -v 'JPEG\|GIF' Moving files to another directory is a popular use: locate *.suf | xargs -J % mv % /path/to/dir Note that you do not always need to use xargs. locate *.PDF | while read name; do mv $name ${name%.PDF}.pdf done There's lots more you can do with it. Your imagination is almost your only limitation. :-) -- David S. Jackson[EMAIL PROTECTED] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= And now for something completely the same. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Shell guru needed.
Hey guys. heres the skinny. I have a huge library and i want to organize it. I want find to go through recursively, and move any pdf files it finds to a certain directory. I need an example piece of script on how i would confront this. It will save me hours if not days so thanks in advance. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
RE: Shell guru needed.
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of mike Sent: Thursday, January 02, 2003 5:04 PM To: [EMAIL PROTECTED] Subject: Shell guru needed. Hey guys. heres the skinny. I have a huge library and i want to organize it. I want find to go through recursively, and move any pdf files it finds to a certain directory. I need an example piece of script on how i would confront this. It will save me hours if not days so thanks in advance. okay, I am no expert, but here is a shot: %find /path/to/search -name '*.pdf' -exec mv /destination/directory I am a bit uncertain if the last part is correct, but this is close to what you want, I think. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Shell guru needed.
On Thu, Jan 02, 2003 at 08:03:37PM -0500, mike wrote: Hey guys. heres the skinny. I have a huge library and i want to organize it. I want find to go through recursively, and move any pdf files it finds to a certain directory. I need an example piece of script on how i would confront this. It will save me hours if not days so thanks in advance. First, turn on line-wrapping in your MUA. find /path/to/my/libarary -name *.pdf -exec mv {} /new/dir/{} \; Nathan To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Shell guru needed.
mike wrote: Hey guys. heres the skinny. I have a huge library and i want to organize it. I want find to go through recursively, and move any pdf files it finds to a certain directory. I need an example piece of script on how i would confront this. It will save me hours if not days so thanks in advance. you don't say if you need to preserve any of the path information when you move the file. The other poster's suggestion might work: my take on it would be to use a for loop: for i in `find /some/dir -name *.pdf`; do mv $i /some/other/dir; done -- Paul Beard: seeking UNIX/internet engineering work http://paulbeard.no-ip.org/paulbeard.html 8040 27th Ave NE Seattle WA 98115 / 206 529 8400 There's no real need to do housework -- after four years it doesn't get any worse. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Shell guru needed.
mike wrote: Hey guys. heres the skinny. I have a huge library and i want to organize it. I want find to go through recursively, and move any pdf files it finds to a certain directory. I need an example piece of script on how i would confront this. It will save me hours if not days so thanks in advance. To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message This should do it. Note the use of back-ticks to execute a command for f in `find . -name *pdf` do mv $f /target-directory done To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Shell guru needed.
On Thu, Jan 02, 2003 at 05:52:55PM -0800, Nathan Kinkade wrote: On Thu, Jan 02, 2003 at 08:03:37PM -0500, mike wrote: Hey guys. heres the skinny. I have a huge library and i want to organize it. I want find to go through recursively, and move any pdf files it finds to a certain directory. I need an example piece of script on how i would confront this. It will save me hours if not days so thanks in advance. First, turn on line-wrapping in your MUA. find /path/to/my/libarary -name *.pdf -exec mv {} /new/dir/{} \; Nathan Sorry, I wasn't thinking hereafter I double check the man page I saw that -exec replaces {} with the path, not just the file namethe above will not work...use the if;do;done syntax that someone else has already posted. Thanks! Nathan To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: Shell guru needed. [Ahhhh! Sorry, but one more...]
On Thu, Jan 02, 2003 at 05:58:11PM -0800, Nathan Kinkade wrote: On Thu, Jan 02, 2003 at 05:52:55PM -0800, Nathan Kinkade wrote: On Thu, Jan 02, 2003 at 08:03:37PM -0500, mike wrote: Hey guys. heres the skinny. I have a huge library and i want to organize it. I want find to go through recursively, and move any pdf files it finds to a certain directory. I need an example piece of script on how i would confront this. It will save me hours if not days so thanks in advance. First, turn on line-wrapping in your MUA. find /path/to/my/libarary -name *.pdf -exec mv {} /new/dir/{} \; Nathan Sorry, I wasn't thinking hereafter I double check the man page I saw that -exec replaces {} with the path, not just the file namethe above will not work...use the if;do;done syntax that someone else has already posted. Thanks! Nathan Ar! I aplogize to reply to my own message a second time!, but something didn't sit well with me after my last reply so I double checked my syntax and found that my original command would work with two modifications -quote *.pdf and remove second {}: find /path/to/dir -name *.pdf -exec mv {} /new/dir \; ..that should do it, but the other suggestions are just as easy...whichever. Sorry for the wasted bandwidth! I'm done now! :) Nathan To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message