![]() |
|
|
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 12:30 PM |
| bash/awk scripting help (creating OLD new users) | Jukai | Shell Programming and Scripting | 2 | 10-17-2006 06:36 AM |
| creating directories | carlvernon | UNIX for Dummies Questions & Answers | 3 | 06-01-2006 02:45 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Bash and Awk for creating directories and moving files
I have a security system that FTPs the camera files to my machine, however I want to sort the pictures (taken every 30s) into directories by hour.
Every picture uses the following file format. yymmddhhmmsstt.jpg (where tt is the milliseconds) I am thinking the for loop is best for file in *.jpg do ?here? done I know its very vague, however the end result is I am guessing use awk (or better?) to create variables from the yy mm dd hh parts of the filenames, then creating directories based on those variables nested with a check to see if the directory exists, creating the directory if it doesnt. i.e. (the way I imagine it working, I dont know how to actually construct the script to do this) for file in 08072400123200.jpg do %y=08 %m=07 %d=24 %h=00 if not exist directory %y - mkdir %y if not exist directory %y/%m - mkdir %y/%m if not exist directory %y/%m/%d - mkdir %y/%m/%d if not exist directory %y/%m/%d/%h - mkdir %y/%m/%d/%h mv %y%m%d%h*.jpg %y/%m/%d/%h done Moving all the pictures taken within that hour into the respective subdirectories. Any help would be much appreciated. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|