![]() |
Any decent shell scripters in the house?
I have a directory 'x' that I need to to move all .jpg's from and put them into another folder. The directory 'x' has many other folders inside of it so this will need to be a recursive string. Who can help? I'll throw you a bone via paypal or something if needed.
|
btw this is for freebsd/bash
|
come on peoples.. wheres fuzebox/rob
|
if you can run a php script to do it i could help you out (i generally use php instead of sh for most shell scripts anyway, so i'm pretty rusty on actual sh scripting)
|
I think that is very simple to do without a script unless i don't understand what you want.
|
I probably could use a php script
|
directory 'x' has many sub directories within it each with multiple .jpg's
I basically want to move (or copy if needed) all .jpg's from within these sub directories into one directory 'y' so that 'y' contains all .jpg's from 'x' and it's sub directories. |
just tried to hit you on icq, i can help you out, just have a few quick questions
|
hello, i can do that, just explain me..
you have a tree where you want to take all jpgs out and put it where? i just need that you can run a php, if you have a webserver in that machine is very easy to do, if not we just have to download a php and unzip it in any folder |
this is gonna be close
find (top level directory) / -name *.jpg -print | mv (new directory) that should start you that may recreate the structure of the original dir ( i dont remember for sure) if so you can put it in a for x in loop something like this for x in `ls -1 -r (top level directory)/*.jpg` do mv x (newdirectory)/. done |
do you want jpg's in subdirectories of x to show up in corresponding subdirectories in y or just in the top level y folder?
|
I don't want it to create any sub directories in 'y' just dump ALL jpg's from 'x' and recursive directories
|
Quote:
for x in `ls -1 -r (top level directory)/*.jpg` do mv $x (newdirectory)/. done |
PHP Code:
EDIT: just saw mike souths post, as a shell script that'd probably work a little easier then mine, atleast you have a backup. |
thanks for the suggestions. what about this, i realize it's for copying and not moving
find $SRC -iname '*.jpg' -exec cp '{}' ${DEST}/ \; |
yes thats for copying not moving...I gave you a for...do loop that will do what you want
its a shell script |
god bless linux
|
I would prefer to have it not overwrite files with the same name but that gets more complicated
|
Quote:
|
Quote:
|
my shell scripting is a tad rusty and I dont have man pages here but
a=0 for x in `ls -1 -r (top level directory)/*.jpg` do a++ mv $x (newdirectory)/$x$a.jpg done will be on the right track though you may have to snip out the first .jpg with a substr command if that gives you .jpg twice (and I think it will) Im flying by the seat of my pants here but you get the gist yer on a UNIX system (or derivative) use man pages for substr for the syntax man substr |
http://www.linuxquestions.org/questi...-files-199134/
this might work: for i in `find <directory> -type d`; do cp *.jpg $i; done |
OK people $50 to the first person that gives me this script. I think mikesouth is closest to what I'm looking for but it needs to be a script that doesn't need me hacking it to get it working. I would prefer not to have a php script, just a plain old bash one like Mike is proposing. It must not rewrite other .jpgs with the same name but instead rename the file names incrementally if it spots duplicates.
|
BTW, I am not available on ICQ today..
|
bump to give someone money
|
bump, would like to have this script in my hand today
|
save the code below into a file call it whatever you like and run it like so
python nameofscript.py foldertoprocess ------------------------------- PHP Code:
|
Have you tested it out? Will it dump all .jpg files into ONE directory 'y' without overwriting existing files with the same name?
|
Quote:
|
Quote:
|
Jesus tapdancing Christ.
Code:
#!/bin/bash |
Quote:
|
yes it will dump everything into one folder... those were the specs asked for
|
grouchyadmin, shoot me an email to area51 at gmail please
|
Quote:
I hit you up as requested. |
Oh, incidentally, this should actually do what you want without being quite so obnoxious. I don't trust having a 'smart' shell; just basic utilities that have been in UNIX since the 70s.
Code:
#!/bin/sh |
All times are GMT -7. The time now is 07:17 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123