14,000 hints and counting!

The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to remove spaces from filenames
Authored by: hellesoe on Mar 10, '08 03:08:06PM

the original script works fine, but would it be possible to make it work on all underlying files and directories?

I need to run a shell script to remove spaces from files and file names in a certain folder every day. can this be done??

A script to remove spaces from filenames
Authored by: maintain1 on Mar 10, '08 05:15:10PM

#!/usr/bin/perl -w

# mvSpace.pl
# WARNING
## This will overwrite files if they have the same name
## So say we have file 1, f ile1, file 1
# After the script we will have one folder called folder1
#
# Created by mar8 on 3/10/08.
#
# the chdir command should change to a users home directory
chdir;
# you could enter the full path name to the folder
$workingDir = "\./Documents/spacefolder/"; opendir DH, "$workingDir" or die ;
my @workingFiles;
my $workingFiles_r = \@workingFiles; while ($_ = readdir(DH)) {

next if $_ eq "." or$_ eq ".." ;
push @{workingFiles_r}, $_; } closedir DH; foreach (@{workingFiles_r}) { my$input = "$workingDir$_";
#print "my input is equal to ", $input,"\n"; s/\ //g; my$output = "$workingDir$_";
#print "my output is equal to ", $output,"\n"; if ("$input" ne "$output") { rename "$input", "$output" or warn "Can't move file:$!";
}
}

A script to remove spaces from filenames
Authored by: degiy on Aug 13, '10 03:06:00AM

>out;ls -1 | grep ' ' | tr ' ' '!' | while read a ; do b=echo $a | tr '!' '_'; echo "mv ,$a, \$b" ;done | tr , \' | tr ! ' ' > out ; . ./out; \rm -f out