Debian Codegraph @

blank-rename.sh

raw symbols SCIP
1 #! /bin/bashscip-shell filesystem . . `/bin/bash`.
2 # blank-rename.sh
3 #
4 # Substitutes underscores for blanks in all the filenames in a directory.
5
6 ONE=1 # For getting singular/plural right (see below).
7 number=0 # Keeps track of how many files actually renamed.
8 FOUND=0 # Successful return value.
9
10 for filename in * #Traverse all files in directory.
11 do
12 echoscip-shell system . . echo. "$filename" | grepscip-shell system . . grep. -q " " # Check whether filename
13 if [scip-shell system . . `[`. $? -eq $FOUND ] #+ contains space(s).
14 then
15 fname=$filename # Yes, this filename needs work.
16 n=`echoscip-shell system . . echo. $fname | sedscip-shell system . . sed. -e "s/ /_/g"` # Substitute underscore for blank.
17 mvscip-shell system . . mv. "$fname" "$n" # Do the actual renaming.
18 let "number += 1"
19 fi
20 done
21
22 if [scip-shell system . . `[`. "$number" -eq "$ONE" ] # For correct grammar.
23 then
24 echoscip-shell system . . echo. "$number file renamed."
25 else
26 echoscip-shell system . . echo. "$number files renamed."
27 fi
28
29 exit 0