0

I would like to replace the "Screenshot" substring with "Ss" for all the files in the current directory (if easy, add for subfolders). Currently I have this code, but needs to be completed/replaced:

#!/bin/bash
for f in *; do
echo "${f}" | cut -c1-10
done

Thank you

1 Answers1

0
for f in *; do 
  mv $f ${f/Screenshot/Ss}
done

if need move to sub directory

mkdir -p foo
for f in *; do 
  mv $f ./foo/${f/Screenshot/Ss}
done

if your filename contain space, make sure to put the variables in double quotes.

mkdir -p foo
for f in *; do
  mv "$f" "${f/origin with space/replace name}" 
done
LianSheng
  • 448
  • 5
  • 17