Doorgaan naar hoofdcontent

Create Directory Structure Based on Date of Files

Whenever you have 10k picture to look through in one directory you know it takes forever to load those thumbnails.
And to find that perfect picture from Christmas 2000 it takes forever.
Wouldn't it be nice to just go to the folder 200012 and see all the pictures you made in december of the year 2000.
Well with a few commands you can actually do this real quickly.

First of all , if you already have somekind of folder structure you might move or copy everything to one root folder.

Here is the "flattening" command for e.g. all jpg files
find . -name "*.JPG" -print0 | xargs -0 cp --target-directory ./test/

After you flattenend your directory
lets create the date folders:
mkdir `ls -l --time-style=+"%Y%m" | awk '{print $6}' | sort | uniq` 

So after this step move all the files to there correct folder:
For this step I couldn't get it without a script
So I made this little bash script which uses rather cool features of bash:

  #!/bin/bash
   IFS=$'\n'
   a=`ls -l --time-style=+"%Y%m" | awk '/^-/{print "mv "$7 " ./"$6"/"$7}'`
   for i in $a
   do
           echo $i
           eval $i
   done;

Reacties

Populaire posts van deze blog

Add Costum Keyboard Layout to XFCE

How to create this keyboard layout for Xfce : Works also on Mate!!!!   It is a lightly modified version of the dvorak programmers layout. I changed the lower left row. So you can easily undo, cut, copy & paste         with your left hand and keep the other hand on your mouse. Step 1. Edit file: /usr/share/X11/xkb/symbols/us Insert this snippit: // programmer Dvorak wim's style, by Wim Stockman <wim.stockman at gmail dot com> // Main features: Numbers are in shift position (like French), symbols have been // switch position of z x c v to the bottom left for easy shortcut handling partial alphanumeric_keys xkb_symbols "dvp-wim" { include "us(dvorak)" name[Group1] = "English (programmer Dvorak Wims style ZXCV)"; // Unmodified Shift AltGr Shift+AltGr // symbols row, left side key <TLDE> { [ dollar, asciitilde, dead_tilde ] }; key <AE01> { [ ampersand, percent ] }; key <AE02> { [ bracketleft, 7, currency ],...

Install Arch Linux on Raid0 with GPT and Grub 2

Install Arch Linux on Raid0 with GPT and Grub 2 First start by downloading the iso. dd it onto usb stick  boot iso then start by setting up internet connection test it : ping www.google.com Load the appropriate RAID (e.g. raid0 , raid1 , raid5 , raid6 , raid10 ) modules.  We will use raid0, and raid1 modprobe raid0 modprobe raid1 Prepare Hard Drives Each drive will have 100Mb for /boot these will be in raid1 for safety The / partition takes the remainder of the drive install gdisk for formatting in GPT pacman-db-upgrade pacman -Syy pacman -S gptfdisk gdisk /dev/sda Add a new partition: n Select the default partition number: Enter Use the default for the first sector: Enter For sda1 type the appropriate size in MB (i.e. +100MB and +2048M ).  Select BIOS BOOT PARTITION as the partition type: ef02  !!!very important Write the table to disk and exit: w Repeat for the second partition on /dev/sda but for step 4 just press ENTER...

Working with pdf files on the command line

PDFTK great tool for rearranging your pdf file. Howto join multiple pdf's together: e.g. you want to join the files: BRO_001.pdf BRO_002.pdf BRO_003.pdf the command is 'cat' from concatenate pdftk BRO_001.pdf BRO_002.pdf BRO_003.pdf cat output Joined.pdf Or even faster pdftk BRO_00* cat output Joined.pdf the cat command accept page ranges 1-end  (the whole document) 6-4-2  pages 6 4 2 in that order even odd r1-r2  last page and second last page