New Posts  All Forums:Forum Nav:

Recursive Move - Page 3

post #21 of 27
Thread Starter 
I'll keep working on the perl script - it's almost where I want it to be
It goes to eleven
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6300 DS3 EVGA 8600GTS 2GB XMS2 DDR2-800 
Hard DriveOSMonitorKeyboard
1.294 TB Arch Linux/XP Samsung 226bw Eclipse II 
PowerCaseMouse
Corsair 520HX Lian-Li v1000B Plus G7 
  hide details  
Reply
It goes to eleven
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6300 DS3 EVGA 8600GTS 2GB XMS2 DDR2-800 
Hard DriveOSMonitorKeyboard
1.294 TB Arch Linux/XP Samsung 226bw Eclipse II 
PowerCaseMouse
Corsair 520HX Lian-Li v1000B Plus G7 
  hide details  
Reply
post #22 of 27
I know everyone must be thinking it but I will say it.........this is awesome!!! LOL

sorry for intruding btw
post #23 of 27
Quote:
Originally Posted by rabidgnome229 View Post
That doesn't work :|
It breaks up the filename by spaces and tries to move each word
so when it gets to
Somebody - something.m4a
it tries to move
Somebody
and
something.m4a
why do you have spaces in your file names?
Atlantis
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Athlon(tm) 64 X2 Dual Core Processor 6400+ Asus M2N-SLI deluxe bfg tech geforce 7600 gt oc 1 GB corsair xms ddr2 
Hard DriveOSMonitorKeyboard
80 GB sata +320 GB sata Gentoo:win2k3 ACER micro wireless 
PowerCaseMouse Pad
350w need 600w TT sviking the "blue mouse pad" 
  hide details  
Reply
Atlantis
(13 items)
 
  
CPUMotherboardGraphicsRAM
AMD Athlon(tm) 64 X2 Dual Core Processor 6400+ Asus M2N-SLI deluxe bfg tech geforce 7600 gt oc 1 GB corsair xms ddr2 
Hard DriveOSMonitorKeyboard
80 GB sata +320 GB sata Gentoo:win2k3 ACER micro wireless 
PowerCaseMouse Pad
350w need 600w TT sviking the "blue mouse pad" 
  hide details  
Reply
post #24 of 27
Thread Starter 
Quote:
Originally Posted by General View Post
why do you have spaces in your file names?
Cuz they're songs :\\

got the perl script how I want it - I didn't want to keep folder structure intact during the move. My file is attached as a .txt - just change the extension

Tomorrow I will clean up the input method and add options to keep folder structure intact
It goes to eleven
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6300 DS3 EVGA 8600GTS 2GB XMS2 DDR2-800 
Hard DriveOSMonitorKeyboard
1.294 TB Arch Linux/XP Samsung 226bw Eclipse II 
PowerCaseMouse
Corsair 520HX Lian-Li v1000B Plus G7 
  hide details  
Reply
It goes to eleven
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6300 DS3 EVGA 8600GTS 2GB XMS2 DDR2-800 
Hard DriveOSMonitorKeyboard
1.294 TB Arch Linux/XP Samsung 226bw Eclipse II 
PowerCaseMouse
Corsair 520HX Lian-Li v1000B Plus G7 
  hide details  
Reply
post #25 of 27
Mine kept their file structure.

EX)
Dir to search: /home/user/music
move to: /mnt/backup

full path to a song:
/home/user/music/The Strokes/First Impressions Of Earth/01 - You Only Live Once.flac



makes directory: /mnt/backup/The Strokes/First Impressions Of Earth

Moves song
from: /home/user/music/The Strokes/First Impressions Of Earth/01 - You Only Live Once.flac
to: /mnt/backup/The Strokes/First Impressions Of Earth/01 - You Only Live Once.flac
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
post #26 of 27
Thread Starter 
Quote:
Originally Posted by dangerousHobo View Post
Mine kept their file structure.
Yah - I'm just going to stick that code back in along with an if or two. Nothing major
It goes to eleven
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6300 DS3 EVGA 8600GTS 2GB XMS2 DDR2-800 
Hard DriveOSMonitorKeyboard
1.294 TB Arch Linux/XP Samsung 226bw Eclipse II 
PowerCaseMouse
Corsair 520HX Lian-Li v1000B Plus G7 
  hide details  
Reply
It goes to eleven
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6300 DS3 EVGA 8600GTS 2GB XMS2 DDR2-800 
Hard DriveOSMonitorKeyboard
1.294 TB Arch Linux/XP Samsung 226bw Eclipse II 
PowerCaseMouse
Corsair 520HX Lian-Li v1000B Plus G7 
  hide details  
Reply
post #27 of 27
I must say I like that Getopt.

Code:
#!/usr/bin/perl

use warnings;
use strict;
use Getopt::Long;
use Cwd;

# Recursive move script
# Moves through either the current directory or a specified directory
# and its subdirectories looking for files containing a specified string
# filetype or both
#
# Revision 3 5/23/07 - authors rabidgnome229 and dangerousHobo
# originally by dangerousHobo

# $s_dir is the original directory
# $d_dir is the directory the files will be moved too

my $s_dir = getcwd();
my $d_dir;
my $type;

GetOptions("t=s" => \\$type, "s=s" => \\$s_dir, "d=s" => \\$d_dir);

if($type =~ /^null$/ ||$d_dir =~ /^null$/ ) {die "Usage: mvrec [-s] source [-d] destination\
   or: mvrec [-s] source [-d] destination [-t] filetype\
";}
my $list = `ls -R -1 $s_dir`;
my @array = split(/\
/, $list);

my $mid; # The sub directory the file was under $o_dir
my $dir; # The full path to the directory the file is in
my $move; # Full path to the file to be moves
my $dest; # Full path to where the file is to be moved

foreach my $m (@array){
    if ($m =~ /:$|:\
$/){
        $dir = $m;
        chop ($dir);
        $dir .= "/";
        $mid = $dir;
        $mid =~ s/^$s_dir//;
        $mid =~ s/[\\s*]/\\ /g;
        $dest = $d_dir."/".$mid;
        `mkdir "$dest"`;
    }elsif ($m =~ /\\.$type$|\\.$type\
$/){
        my $file = $m;
        $file =~ s/[\\s*]/\\ /g;
        $move = $s_dir."/".$mid.$file;
        #print ("MOVE $move\
HERE $dest\
"); # For debugging
        `mv "$move" "$dest"`;
    }
}
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
BlackMesa
(14 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II x6 Gigabyte XFX RF460 16gb G.Skill 
Hard DriveHard DriveOSMonitor
OCZ Vertex2 Sata II Coorsair Force GS Sata III Debian (testing) Shimian 27" 
KeyboardMouse
Filco w/ blue cherries Who needs a mouse? 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix