Judicious use of symbolic links and bash regular expressions can also make
short work of this.

If you do
cd ~/folder1/folder2/folder3/folder4/folder5
ln -s ../../.. folder2

you will have a folder under folder5 called folder2 which points to your
original folder2 directory

You can then simply
mv filename folder2/

to move each file.

Bash regular expressions can come in handy when moving lots (but not all)
files. For example

mv DSCF0[4-6]*.jpg will move everything between DSCF04... to DSCF06... with
one statement.

Google for more help, since I'm not too good with regular expressions,
myself.

Once you are done, you can run
rm folder2
in folder5 to remove the symlink (but not the original directory).

Note also that a symlink to a folder above your current location in the
hierarchy does create an infinite loop, Be careful when using recursive
commands!

If it is likely that you are going to be moving things to folder2 regularly
from a variety of location, you may want to create a bash script, which
takes a filename as an argument:

#!/bin/sh
# moves a given filename to ~/folder1/folder2/
mv $1 ~/folder1/folder2/

Save this as folder2 in your home directory (or somewhere in your path: I
use ~/bin/ which I add to path).
Then run
chmod 755 folder2
to make it executable.

Then you can type

folder2 filename

to move filename from any directory to ~/folder1/folder2

Have fun!
Marti



On 22 November 2010 13:26, Simon P Smith <[email protected]>wrote:

> On 22/11/2010 18:16, StarLion wrote:
> >> m...@computer:~#/folder1/folder2/folder3/folder4/folder5 mv blah
> blah.........
> >>
> >> Now I want to go back to work in folder2, what the easy command to get
> me back
> >> there??
> > Assuming you're working in folder5 in your example, running 'cd ..'
> > will go back to folder4.
> > To go down two levels, you want 'cd ../..' and for three, just add
> another '/..'
> > _________________________________________________________________
> If you are using these regularly then you can also use aliases to create
> shortcuts to
> the directories (i.e. gowww is alised on my system to /home2/var/www/site1/
>
> Alternatively you can use symlinks to create pointers to those
> directories, i.e.
> my /backup is a link to /media/nfs/buffnas1/backups/serverwww1
>
> Si
>
> --
> Next meeting:  Somewhere quiet, Bournemouth, ???day 2010-12-?? 20:00
> Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
> How to Report Bugs Effectively:  http://goo.gl/4Xue
>
--
Next meeting:  Somewhere quiet, Bournemouth, ???day 2010-12-?? 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue

Reply via email to