Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Copying items in subfolders into a parent folder...

Copying items in subfolders into a parent folder...
Thread Tools
Mac Enthusiast
Join Date: Oct 2000
Location: Toronto
Status: Offline
Reply With Quote
Nov 16, 2006, 10:08 AM
 
Hi all,

I have a directory, and within that subfolders (and some of these folders have subfolders within them as well). I'd like an easy way to copy the files within these folders to the parent directory (to not overright if the name already exists in the parent dir), and to delete the original subfolder the file was in (if its empty). Is there an easy way to do this?

Any help is appreciated. TIA
     
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status: Offline
Reply With Quote
Nov 16, 2006, 10:52 AM
 
a short shell script will do the trick.

a quick and dirty script would be something like this:

for i in `ls`; do mv $i ../$i; done

it won't do exactly what you want, it will overwrite duplicate files..., but might get you started.

to get example code google for shell scripts that use the 'find' command
search for: bash find mv

lots of people are working on similar problems so there are plenty of pointers around like this:
how to tell bash to move files to another folder? - LinuxQuestions.org

also check out this: https://gna.org/projects/ff-bash/

you might also try using Automator (in the applications folder) to script the finder
You can take the dude out of So Cal, but you can't take the dude outta the dude, dude!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:50 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2