baptx

copy_folder_by_filename

Jan 26th, 2014
106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. IFS=$'\n'
  2. if [ $# == 2 ]; then
  3.     if [ ! -d $1 ]; then
  4.     echo "Error: directory $1 does not exist"
  5.     else
  6.     dir=$1
  7.     len=$((${#dir} + 1))
  8.     if [ ! -d $2 ]; then
  9.         mkdir $2
  10.     fi
  11.     for i in `ls -R $1`
  12.     do
  13.         src=`echo $i | cut -d : -f 1`
  14.         if [ -d $src ]; then
  15.         dir=$src
  16.         fi
  17.         dest=$2/`echo $dir | cut -c $len-`
  18.         if [ ! -d $dest ]; then
  19.         mkdir $dest
  20.         fi
  21.         if [ -f $dir/$i ]; then
  22.         cp -v $dir/$i $dest
  23.         fi
  24.     done
  25.     fi
  26. else
  27.     echo "On some MP3 player, the play order depends on wich files are copied first.
  28. Folder files will be copied alphabetically by filename, subfolders included.
  29.  
  30. Usage: $0 source_directory destination_directory"
  31. fi
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×