Advertisement
deckoff

Move Files to a folder with the same name

Aug 5th, 2012
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.40 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. #This script allows files with the same name and different extension to be sorted in a folder with name, same as the file name. This is useful, when I download my Linux Journal magazines in different file formats and have to import them into Calibre
  5.  
  6. books="*.*"
  7.  
  8. for f in ${books}
  9. do
  10.     dirname=$(echo $f | cut -f1 -d'.' )
  11.      echo $dirname
  12.      mkdir -p $dirname
  13.      mv $f $dirname
  14. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement