Re: create directories based on directory contents
- From: Milan Babuskov <mbabuskov@xxxxxxxxx>
- Date: Tue, 30 Jan 2007 09:56:32 +0100
gmail@xxxxxxxxxxxxxxxx wrote:
Suppose I have the following directory structure:
photos
|-AAA_100.jpg
|-AAA_101.jpg
|-AAA_102.jpg
|-XXXXX_100.jpg
|-XXXXX_101.jpg
|-XXXXX_100.jpg
|-ZZ_100.jpg
|-ZZ_101.jpg
is it possible to issue some commands that will automatically create 3 subdirectories, AAA, XXXXX, ZZ and subsequently move all the files into these folders?
Perhaps something like:
for i in *_*; do mkdir `echo $i | sed s/_*.//`; done
for i in *_*; do mv $i `echo $i | sed s/_*.//`; done
Untested, and probably not the most efficient, but might give you some ideas.
--
Milan Babuskov
http://njam.sourceforge.net
.
- References:
- create directories based on directory contents
- From: gmail
- create directories based on directory contents
- Prev by Date: Re: Top of printout is cut off
- Next by Date: Re: A file that can be seen... but doesn't exist!
- Previous by thread: create directories based on directory contents
- Next by thread: Re: create directories based on directory contents
- Index(es):
Relevant Pages
|