![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| creating directories on the same box | vivek_damodaran | HP-UX | 3 | 11-14-2007 03:06 PM |
| Tar and moving directories | stocksj | SUN Solaris | 2 | 11-13-2007 11:33 AM |
| moving directories to new directories on multiple servers | mackdaddy07 | Shell Programming and Scripting | 0 | 04-06-2007 11:30 AM |
| bash/awk scripting help (creating OLD new users) | Jukai | Shell Programming and Scripting | 2 | 10-17-2006 05:36 AM |
| creating directories | carlvernon | UNIX for Dummies Questions & Answers | 3 | 06-01-2006 01:45 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Well, its working (for those out there that stumble across this site for a similar script)
Its not elegant, sane or other ... but it works. If the better experienced here can clean it up and solve the elegant/sane issues then it would be great ![]() Code:
#!/bin/bash -x
for file in *.jpg; do
YY=`echo $file | awk '{split($0,a,""); print a[1]a[2]}'`
MM=`echo $file | awk '{split($0,a,""); print a[3]a[4]}'`
DD=`echo $file | awk '{split($0,a,""); print a[5]a[6]}'`
HH=`echo $file | awk '{split($0,a,""); print a[7]a[8]}'`
if [ -d $YY ]
then
if [ -d $YY/$MM ]
then
if [ -d $YY/$MM/$DD ]
then
if [ -d $YY/$MM/$DD/$HH ]
then
mv $YY$MM$DD$HH*.jpg $YY/$MM/$DD/$HH
else
mkdir $YY/$MM/$DD/$HH
fi
else
mkdir $YY/$MM/$DD
fi
else
mkdir $YY/$MM
fi
else
mkdir $YY
fi
done
|
|
||||
|
Quote:
Instead of a single directory 08072511 I need them nested like >08 ->07 -->25 --->11 |
|
||||
|
Ops, fast reading
![]() Code:
for i in *.jpg;do d=.$(sed 's/\(..\)/\/\1/g' <<< ${i:0:8});test -d $d || mkdir -p $d ;mv $i $d;done
Code:
$ uname -a Linux test 2.6.18-6-686 #1 SMP Sun Feb 10 22:11:31 UTC 2008 i686 GNU/Linux Last edited by danmero; 07-24-2008 at 10:22 PM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|