| 
		
			
			
				
			
			
				 
			
			
				
			
		 | 
		
			
			
				 
			
				
			
		 | 
	||||
| 
				Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.  You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us.  | 
		
		 
		![]()  | 
	
		
			
  | 	
	
	
		
		|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. | 
| 
		 | 
	Thread Tools | 
| 
			
			 | 
		#1 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
			
			 
				
				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. 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#2 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 btw this is for freebsd/bash 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#3 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 come on peoples.. wheres fuzebox/rob 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#4 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Industry Role:  
				Join Date: Jul 2007 
				Location: Intraweb 
				
				
					Posts: 274
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 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) 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#5 | 
| 
			
			
			
			 Confirmed User 
			
		
			
				
			
			
			Join Date: Sep 2006 
				Location: here and there. 
				
				
					Posts: 196
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 I think that is very simple to do without a script unless i don't understand what you want. 
		
	
		
		
		
		
			
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#6 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 I probably could use a php script 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#7 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 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.  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#8 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Industry Role:  
				Join Date: Jul 2007 
				Location: Intraweb 
				
				
					Posts: 274
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 just tried to hit you on icq, i can help you out, just have a few quick questions 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#9 | 
| 
			
			
			
			 Registered User 
			
		
			
			
			Join Date: May 2008 
				Location: Monterrey, Mexico 
				
				
					Posts: 3
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 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  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#10 | 
| 
			
			
			
			 Confirmed User 
			
		
			
				
			
			
			Industry Role:  
				Join Date: Jun 2003 
				Location: My High Horse 
				
				
					Posts: 6,334
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 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 
				__________________ 
		
		
		
		
	
	Mike South It's No wonder I took up drugs and alcohol, it's the only way I could dumb myself down enough to cope with the morons in this biz.  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#11 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Industry Role:  
				Join Date: Jul 2007 
				Location: Intraweb 
				
				
					Posts: 274
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 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? 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#12 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 I don't want it to create any sub directories in 'y' just dump ALL jpg's from 'x' and recursive directories 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#13 | |
| 
			
			
			
			 Confirmed User 
			
		
			
				
			
			
			Industry Role:  
				Join Date: Jun 2003 
				Location: My High Horse 
				
				
					Posts: 6,334
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
 for x in `ls -1 -r (top level directory)/*.jpg` do mv $x (newdirectory)/. done 
				__________________ 
		
		
		
		
		
			
		
		
	
	Mike South It's No wonder I took up drugs and alcohol, it's the only way I could dumb myself down enough to cope with the morons in this biz.  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#14 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Industry Role:  
				Join Date: Jul 2007 
				Location: Intraweb 
				
				
					Posts: 274
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 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.  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#15 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 thanks for the suggestions. what about this, i realize it's for copying and not moving 
		
	
		
		
		
		
		
	
	find $SRC -iname '*.jpg' -exec cp '{}' ${DEST}/ \;  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#16 | 
| 
			
			
			
			 Confirmed User 
			
		
			
				
			
			
			Industry Role:  
				Join Date: Jun 2003 
				Location: My High Horse 
				
				
					Posts: 6,334
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 yes thats for copying not moving...I gave you a for...do loop that will do what you want 
		
	
		
		
		
		
			its a shell script 
				__________________ 
		
		
		
		
	
	Mike South It's No wonder I took up drugs and alcohol, it's the only way I could dumb myself down enough to cope with the morons in this biz.  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#17 | 
| 
			
			
			
			 Registered User 
			
		
			
			
			Join Date: May 2008 
				Location: Monterrey, Mexico 
				
				
					Posts: 3
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 god bless linux 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#18 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 I would prefer to have it not overwrite files with the same name but that gets more complicated 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#19 | 
| 
			
			
			
			 Confirmed User 
			
		
			
				
			
			
			Industry Role:  
				Join Date: Jun 2003 
				Location: My High Horse 
				
				
					Posts: 6,334
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 not really just add a counter variable in the loop and append it to the filename 
		
	
		
		
		
		
			
				__________________ 
		
		
		
		
	
	Mike South It's No wonder I took up drugs and alcohol, it's the only way I could dumb myself down enough to cope with the morons in this biz.  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#20 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#21 | 
| 
			
			
			
			 Confirmed User 
			
		
			
				
			
			
			Industry Role:  
				Join Date: Jun 2003 
				Location: My High Horse 
				
				
					Posts: 6,334
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 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 
				__________________ 
		
		
		
		
	
	Mike South It's No wonder I took up drugs and alcohol, it's the only way I could dumb myself down enough to cope with the morons in this biz.  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#22 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Industry Role:  
				Join Date: May 2002 
				Location: Toronto 
				
				
					Posts: 8,475
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 http://www.linuxquestions.org/questi...-files-199134/ 
		
	
		
		
		
		
		
	
	this might work: for i in `find <directory> -type d`; do cp *.jpg $i; done  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#23 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 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. 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#24 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 BTW, I am not available on ICQ today.. 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#25 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 bump to give someone money 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#26 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 bump, would like to have this script in my hand today 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#27 | 
| 
			
			
			
			 Registered User 
			
		
			
				
			
			
			Join Date: May 2008 
				Location: miami,fl 
				
				
					Posts: 79
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 save the code below into a file call it whatever you like and run it like so 
		
	
		
		
		
		
			python nameofscript.py foldertoprocess ------------------------------- PHP Code: 
	
			
	
				__________________ 
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#28 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Have you tested it out? Will it dump all .jpg files into ONE directory 'y' without overwriting existing files with the same name? 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#29 | |
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: May 2005 
				
				
				
					Posts: 2,737
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#30 | |
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Industry Role:  
				Join Date: May 2002 
				Location: Toronto 
				
				
					Posts: 8,475
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#31 | 
| 
			
			
			
			 Now choke yourself! 
			
		
			
				
			
			
			Industry Role:  
				Join Date: Apr 2006 
				
				
				
					Posts: 12,085
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Jesus tapdancing Christ. 
		
	
		
		
		
		
			Code: 
	#!/bin/bash TWIRLY1="|" TWIRLY2="/" TWIRLY3="-" TWIRLY4="\" DESTDIR=/tmp WHEREFROM=/home TWIRL=1 for n in `find $WHEREFROM -name \*.jpg -print`; do TWIRL=$TWIRL+1 IF [ $TWIRL -gt 4 ]; then TWIRL=1 fi COUNT=0 if [ -f $DESTDIR/$n ]; then # Ho ho ho. $newname = $RAND`basename $n`; else $newname = `basename $n`; fi echo -n "Imma busy fuckkin up $newname, hold on.. $TWIRL" mv $n $destdir/$newname done echo "" echo "THIS SCRIPT IS SHAREWARE. PLS REGISTER!" 
				__________________ 
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#32 | |
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Join Date: May 2005 
				
				
				
					Posts: 2,737
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#33 | 
| 
			
			
			
			 Registered User 
			
		
			
				
			
			
			Join Date: May 2008 
				Location: miami,fl 
				
				
					Posts: 79
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 yes it will dump everything into one folder... those were the specs asked for 
		
	
		
		
		
		
			
				__________________ 
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#34 | 
| 
			
			
			
			 Too lazy to set a custom title 
			
		
			
			
			Join Date: Dec 2004 
				
				
				
					Posts: 17,513
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 grouchyadmin, shoot me an email to area51 at gmail please 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#35 | 
| 
			
			
			
			 Now choke yourself! 
			
		
			
				
			
			
			Industry Role:  
				Join Date: Apr 2006 
				
				
				
					Posts: 12,085
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Hi Justin. 
		
	
		
		
		
		
			I hit you up as requested. 
				__________________ 
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#36 | 
| 
			
			
			
			 Now choke yourself! 
			
		
			
				
			
			
			Industry Role:  
				Join Date: Apr 2006 
				
				
				
					Posts: 12,085
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 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
PATH=/bin:/usr/bin:/sbin:/usr/sbin
FROMDIR=SET_BASEDIR_FOR_MOVE_FROM_HERE
TODIR=SET_DIR_TO_COPY_IT_TO_HERE
FILETYPE=jpg
APPENDSTART=1
for n in `find $FROMDIR -name \*.$FILETYPE -print`; do
   FILE=`basename "$n"`
   if [ -f "$TODIR/$FILE" ]; then
     while [ $APPENDSTART -le 100 ]; do
       APPENDSTART=`expr $APPENDSTART + 1`
       if [ ! -f "$TODIR/$APPENDSTART$FILE" ]; then
         FILE="$APPENDSTART$FILE"
         break;
       fi
     done
   fi
   echo "Moving '$n' to '$TODIR/$FILE'."
   mv "$n" "$TODIR/$FILE"
done
				__________________ 
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 |