On Fri, 13 Oct 2006 16:31:22 -0000, Grigory Fateyev wrote: > Здравствуйте! > > Пишу скрипт, который должен в директории изменить в именах файлов > символы пробела на символы подчёркивания. Но почему то замена "mv" не > проходит. Что не так? Попробуйте немного Perl-овки :) ######################################################## # # Рекурсивная замена в именах каталогов/файлов: /s+/_/ # created by Aleksander Gorohovski (2006). This is free software. # angel@feht.dgtu.donetsk.ua use File::Find; die "Example usage:\n\t $0 \n" if ! @ARGV; $_="$ENV{PWD}/$_" for(@ARGV); my $a; while(! $a){ @Files=undef; find sub{push @Files,$File::Find::name if $> == 0 || (stat($File::Find::name))[4] == $>},@ARGV; $a=1; for my $df (@Files){ next if !length($df); my @d=split /\//,$df; $d[-1]=~s/\s+/_/g; my $dt=join '/',@d; if($df ne $dt){$a=0,print "$df => $dt\n" if rename($df,$dt)} } } exit; #------------------------------------ Это Вам поможет > #!/bin/bash > > DIR=~/www/testsed/ > IFS="\n" > > if [ -n "$DIR" ]; then > cd $DIR > for file in `ls *`; do > echo "$file" > cf=`echo "$file" | tr ' ' '_'` > echo $cf > if [ $cf != "$file" ]; then > mv "$file" $cf > fi > done > fi > > ~/cut.sh > file 1 > file 2 > file 3 > file_4 > file_1 > file_2 > file_3 > file_4 > mv: невозможно выполнить stat для `file 1\nfile 2\nfile 3\nfile_4': No > such file or directory > >