Reputation: 61
I want to copy all files in a given directory, into the same directory, with a new name (something like: filenameCOPY).
I've tried a few different methods (globbing, cat, cp) but have yet to succeed. Here is where my code is currently at:
#!/bin/bash
if [ "$#" = "1"]
then
if test -d $1; then
for file in $1/*; do
//something
done
else
echo "$1 is not a directory"
fi
Upvotes: 1
Views: 116
Reputation: 16340
I think all you need is something like this:
for file in "$1"/*; do
cp -- "$file" "${file}COPY"
done;
right?
Upvotes: 2