Could you propose a way to copy a list of files from one directory to another.
During copying the script should capitalize the first letter of the filename and lowercase all other letters.
Could you propose a way to copy a list of files from one directory to another.
During copying the script should capitalize the first letter of the filename and lowercase all other letters.
For your consideration:
for i in *;
do
fletter=`echo $i| cut -b 1`; # FIRST LETTER
rest=`echo $i | cut -b 2-`; # THE REST
fletter=`echo $fletter | tr "[a-z]" "[A-Z]"`;# CAPITILIZE FIRST LETTER
rest=`echo $rest | tr "[A-Z]" "[a-z]"`; # LOWER CASE THE REST
cp "$i" "/target/directory/$fletter$rest" ; # COPY TO DESTINATION
done
Here, *
will expand to the files in the current directory. If you want this to be restricted to files only, consider the following:
find . -type f -print0 | while IFS= read -r -d '' i; do
# rest of the script
done
\ls -p | grep -v "/"
to process only files - not directories.