Skip to main content
removed backslashes
Source Link
Sagar
  • 446
  • 3
  • 11

Here is the shell script that will help you. You can choose different date. I used current date. Save the shell script as myrename.sh and call it ./myrename.sh dirname. Where dirname is the name of directory in which files will be affected.

#!/bin/bash
for i in \`ls`ls $1 | grep -E '[0-9]{4}-[0-9]{2}-[0-9]{2}'\`'`
do
    x=\`echox=`echo $i | grep -oE   '[0-9]{4}-[0-9]{2}-[0-9]{2}'\`'`
    y=\`echoy=`echo $i | sed "s/$x/$(date +%F)/g"\`g"`
    mv $1/$i $1/$y 2>/dev/null #incase if old date is same as current date
done

Here is the shell script that will help you. You can choose different date. I used current date. Save the shell script as myrename.sh and call it ./myrename.sh dirname. Where dirname is the name of directory in which files will be affected.

#!/bin/bash
for i in \`ls $1 | grep -E '[0-9]{4}-[0-9]{2}-[0-9]{2}'\`
do
    x=\`echo $i | grep -oE  '[0-9]{4}-[0-9]{2}-[0-9]{2}'\`
    y=\`echo $i | sed "s/$x/$(date +%F)/g"\`
    mv $1/$i $1/$y 2>/dev/null #incase if old date is same as current date
done

Here is the shell script that will help you. You can choose different date. I used current date. Save the shell script as myrename.sh and call it ./myrename.sh dirname. Where dirname is the name of directory in which files will be affected.

#!/bin/bash
for i in `ls $1 | grep -E '[0-9]{4}-[0-9]{2}-[0-9]{2}'`
do
    x=`echo $i | grep -oE   '[0-9]{4}-[0-9]{2}-[0-9]{2}'`
    y=`echo $i | sed "s/$x/$(date +%F)/g"`
    mv $1/$i $1/$y 2>/dev/null #incase if old date is same as current date
done
added 19 characters in body
Source Link
Hunter.S.Thompson
  • 9.2k
  • 7
  • 28
  • 41

Here is the shell script that will help you. You can choose different date. I used current date. Save the shell script as myrename.sh and call it ./myrename.sh dirname. Where dirnamedirname is the name of directory in which files will be affected.
#!/bin/bash for i in `ls $1 | grep -E '[0-9]{4}-[0-9]{2}-[0-9]{2}'` do x=`echo $i | grep -oE '[0-9]{4}-[0-9]{2}-[0-9]{2}'` y=`echo $i | sed "s/$x/$(date +%F)/g"` mv $1/$i $1/$y 2>/dev/null #incase if old date is same as current date done

#!/bin/bash
for i in \`ls $1 | grep -E '[0-9]{4}-[0-9]{2}-[0-9]{2}'\`
do
    x=\`echo $i | grep -oE  '[0-9]{4}-[0-9]{2}-[0-9]{2}'\`
    y=\`echo $i | sed "s/$x/$(date +%F)/g"\`
    mv $1/$i $1/$y 2>/dev/null #incase if old date is same as current date
done

Here is the shell script that will help you. You can choose different date. I used current date. Save the shell script as myrename.sh and call it ./myrename.sh dirname. Where dirname is the name of directory in which files will be affected.
#!/bin/bash for i in `ls $1 | grep -E '[0-9]{4}-[0-9]{2}-[0-9]{2}'` do x=`echo $i | grep -oE '[0-9]{4}-[0-9]{2}-[0-9]{2}'` y=`echo $i | sed "s/$x/$(date +%F)/g"` mv $1/$i $1/$y 2>/dev/null #incase if old date is same as current date done

Here is the shell script that will help you. You can choose different date. I used current date. Save the shell script as myrename.sh and call it ./myrename.sh dirname. Where dirname is the name of directory in which files will be affected.

#!/bin/bash
for i in \`ls $1 | grep -E '[0-9]{4}-[0-9]{2}-[0-9]{2}'\`
do
    x=\`echo $i | grep -oE  '[0-9]{4}-[0-9]{2}-[0-9]{2}'\`
    y=\`echo $i | sed "s/$x/$(date +%F)/g"\`
    mv $1/$i $1/$y 2>/dev/null #incase if old date is same as current date
done
Source Link
Sagar
  • 446
  • 3
  • 11

Here is the shell script that will help you. You can choose different date. I used current date. Save the shell script as myrename.sh and call it ./myrename.sh dirname. Where dirname is the name of directory in which files will be affected.
#!/bin/bash for i in `ls $1 | grep -E '[0-9]{4}-[0-9]{2}-[0-9]{2}'` do x=`echo $i | grep -oE '[0-9]{4}-[0-9]{2}-[0-9]{2}'` y=`echo $i | sed "s/$x/$(date +%F)/g"` mv $1/$i $1/$y 2>/dev/null #incase if old date is same as current date done